JDK-4904370 : JDK 1.4 and the JIS0208 character set encoding
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.4.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_8
  • CPU: sparc
  • Submitted: 2003-08-11
  • Updated: 2003-11-12
  • Resolved: 2003-10-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.1_07 07Fixed
Related Reports
Relates :  
Description
The problem is with jdk 1.4 and the JIS0208 character set encoding.  Its
not encoding double byte character data correctly.  I attached a test
program for SUN to run.  The output of this test using the i18n.jar file
is:

26085
26412
38651
27671
26666
24335
20250
31038

The output of the same test using the charsets.jar file is:

70
124
75
92
69
69
53
36
51
116
60
48
50
113
60
82

Test code to demonstrate the problem:

public class CIITest {

  public CIITest() {

      byte [] ciiarray;

      //
      //Create a byte array containing the 16 bytes that will be encoded into the JIS0208 character set.
      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 {
         String temp = new String(ciiarray, "JIS0208");  //convert the byte array into a string with the JIS0208 character set.

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

      }
      catch (Exception e) {System.out.println(e);}

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


Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.1_07 1.4.2_04 generic FIXED IN: 1.4.1_07 1.4.2_04 INTEGRATED IN: 1.4.1_07 1.4.2_04
2004-06-14

WORK AROUND The customer can fix the problem by removing the charsets.jar file and adding the i18n.jar file (from a JDK 1.3 install) in the jre/lib directory where they reside. However they won't have this option in a client's environment so its imperative for SUN to understand this issue and not give them this as a solution.
2004-06-11

EVALUATION Looks to be a duplicate of 4766311 (committed to fix Tiger) ###@###.### 2003-08-11
2003-08-11