United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4991519 : Encoding Unicode to JIS0208 Throw exception

Details
Type:
Bug
Submit Date:
2004-02-09
Status:
Resolved
Updated Date:
2004-04-23
Project Name:
JDK
Resolved Date:
2004-04-23
Component:
core-libs
OS:
windows_nt,generic
Sub-Component:
java.nio.charsets
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.2_04
Fixed Versions:
1.4.2_04 (04)

Related Reports
Duplicate:

Sub Tasks

Description
Since J2SDK 1.4.2_04, an exception is threw when run the following testcase

java.lang.IllegalArgumentException: Illegal replacement
        at java.nio.charset.CharsetEncoder.replaceWith(CharsetEncoder.java:262)
        at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:180)
        at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:203)
        at sun.nio.cs.ext.DoubleByteEncoder.<init>(DoubleByteEncoder.java:31)
        at sun.nio.cs.ext.JIS_X_0208$Encoder.<init>(JIS_X_0208.java:74)
        at sun.nio.cs.ext.JIS_X_0208.newEncoder(JIS_X_0208.java:35)
        at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:317)
        at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:308)
        at java.lang.StringCoding.encode(StringCoding.java:365)
        at java.lang.String.getBytes(String.java:573)
        at CIITest.<init>(CIITest.java:41)
        at CIITest.main(CIITest.java:48)

public class CIITest {

  public CIITest() {

      byte[] tfdElement = null;

      String temp = null;

      byte [] ciiarray;

      ciiarray = new byte[16];
      ciiarray[0] = 0x46;
      ciiarray[1] = 0x7c;
      ciiarray[2] = 0x4b;
      ciiarray[3] = 0x5c;
      ciiarray[4] = 0x45;
      ciiarray[5] = 0x45;
      ciiarray[6] = 0x35;
      ciiarray[7] = 0x24;
      ciiarray[8] = 0x33;
      ciiarray[9] = 0x74;
      ciiarray[10] = 0x3c;
      ciiarray[11] = 0x30;
      ciiarray[12] = 0x32;
      ciiarray[13] = 0x71;
      ciiarray[14] = 0x3c;
      ciiarray[15] = 0x52;

      try {
		  System.out.println("Test JIS0208--->Unicode");
          temp = new String(ciiarray, "JIS0208");

          for (int i=0; i<temp.length(); i++) {
             System.out.println("Pos " + i + ": " + (int)temp.charAt(i));
          }
      }
      catch (Exception e) {e.printStackTrace();}

      try {
		  System.out.println("Test Unicode--->JIS0208");
		  tfdElement = temp.getBytes("JIS0208");
		  System.out.println("No exception occurred");
      }
      catch (Exception e) {e.printStackTrace();}

  }
  public static void main(String[] args) {
    CIITest CIITest1 = new CIITest();
  }
}

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
1.4.2_04

FIXED IN:
1.4.2_04

INTEGRATED IN:
1.4.2_04


                                     
2004-06-14
SUGGESTED FIX

*** /tmp/sccs.c8aiNs    Tue Feb 10 16:51:51 2004
--- JIS_X_0208.java     Tue Feb 10 15:54:17 2004
***************
*** 73,79 ****
        public Encoder(Charset cs) {
            super(cs,
                  c2b.getIndex1(),
!                 c2b.getIndex2()
                 );
        }
  
--- 73,80 ----
        public Encoder(Charset cs) {
            super(cs,
                  c2b.getIndex1(),
!                 c2b.getIndex2(),
!                 repl
                 );
        }
  
***************
*** 81,86 ****
--- 82,88 ----
            super(cs,
                 c2b.getIndex1(),
                 c2b.getIndex2(),
+                repl,
                 avg,
                 max);
        }
                                     
2004-06-11
EVALUATION

Will fix in JIS_X_0208 encoder
###@###.### 2004-02-09
                                     
2004-02-09



Hardware and Software, Engineered to Work Together