Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4904370
Votes 0
Synopsis JDK 1.4 and the JIS0208 character set encoding
Category java:char_encodings
Reported Against 1.4.0_00
Release Fixed 1.4.1_07, 1.4.2_04(Bug ID:2073193)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 4997258
Submit Date 11-AUG-2003
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();
  }
}
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.
Evaluation
Looks to be a duplicate of 4766311 (committed to fix Tiger)
  xxxxx@xxxxx   2003-08-11
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang