Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4904370

JDK 1.4 and the JIS0208 character set encoding

XMLWordPrintable

        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();
          }
        }

              ilittlesunw Ian Little (Inactive)
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: