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

Cp943 io converter returns U+0000 and U+FFFD for unconvertable character

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 6u1
    • core-libs

      I tried to run attached testcase (Cp943Test), which checks the Cp943 code range.

      Cp943Test returns U+0000 and U+FFFD for unconvertable character.

      For example,
      0x81ad: 0000
      0x81ae: 0000
      0x81af: 0000
      0x81b0: 0000
      ...
      0x8581: fffd
      0x8587: fffd
      0x85e0: fffd
      0x85f0: fffd

      What's difference these two unconvertable character?
      I think it should returns U+FFFD instead of U+0000.

      =====================================================================================
      import java.io.*;

      class Cp943Test {
          public static void main (String[] args) {
             byte[] test = new byte[2];
             char[] charBuffer = new char[1];
             sun.io.ByteToCharCp943 convertor = new sun.io.ByteToCharCp943();
             for(int i = 0x81; i<= 0xfc; i++) {
                 if (0x9f < i && i < 0xe0) continue;
                 for(int j = 0x40; j <= 0xfc; j++) {
                     if (j == 0x7f) continue;
                     test[0] = (byte) i;
                     test[1] = (byte) j;
                     try {
                        int nc = convertor.convert (test, 0, 2, charBuffer, 0, 1);
                        System.out.printf("0x%02x%02x: %04x\n", i, j, (int)charBuffer[0]);
                     }
                     catch (Exception e) { }
                 }
              }
          }
      }

            sherman Xueming Shen
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: