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

CharsetDecoder.decode of Cp964 fails for single-byte input

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 5.0, 5.0u8
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux honolulu.ilog.fr 2.4.21-0.13mdk #1 Fri Mar 14 15:08:06 EST 2003 i686 unknown


      A DESCRIPTION OF THE PROBLEM :
      The decoder for Cp964 fails to throw a MalformedInputException for
      many single-byte input buffers.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      javac niobug2.java
      java niobug2


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No output.

      ACTUAL -
      0x8E 0x
      0xA1 0x
      0xA2 0xFF0C
      0xA3 0x
      0xA4 0x2581
      0xA5 0x
      0xA6 0x03A0
      0xA7 0x
      0xA8 0x4EA0
      0xA9 0x
      0xAA 0x9EA5
      0xAB 0x
      0xAD 0x
      0xAF 0x
      0xB1 0x
      0xB3 0x
      0xB5 0x
      0xB7 0x
      0xB9 0x
      0xBB 0x
      0xBD 0x
      0xBF 0x
      0xC1 0x
      0xC3 0x
      0xC5 0x
      0xC6 0x6587
      0xC7 0x
      0xC8 0x5216
      0xC9 0x
      0xCA 0x5429
      0xCB 0x
      0xCC 0x8D70
      0xCD 0x
      0xCE 0x602B
      0xCF 0x
      0xD0 0x8868
      0xD1 0x
      0xD2 0x662F
      0xD3 0x
      0xD4 0x8A02
      0xD5 0x
      0xD6 0x634E
      0xD7 0x
      0xD8 0x803D
      0xD9 0x
      0xDA 0x57F7
      0xDB 0x
      0xDC 0x6DF5
      0xDD 0x
      0xDE 0x901E
      0xDF 0x
      0xE0 0x6691
      0xE1 0x
      0xE2 0x840A
      0xE3 0x
      0xE4 0x5ABD
      0xE5 0x
      0xE6 0x7B77
      0xE7 0x
      0xE8 0x98FE
      0xE9 0x
      0xEA 0x7591
      0xEB 0x
      0xEC 0x98AF
      0xED 0x
      0xEE 0x761F
      0xEF 0x
      0xF0 0x981C
      0xF1 0x
      0xF2 0x7FB2
      0xF3 0x
      0xF4 0x6AA2
      0xF5 0x
      0xF6 0x935B
      0xF7 0x
      0xF8 0x9AC1
      0xF9 0x
      0xFA 0x7662
      0xFB 0x
      0xFC 0x9451
      0xFD 0x


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;
      import java.nio.*;
      import java.nio.charset.*;

      public class niobug2 {
        static String toHexString1 (int i) {
          return new String(new char[] { "0123456789ABCDEF".charAt(i) });
        }
        static String toHexString2 (int i) {
          return toHexString1((i>>4)&0x0f)
                 +toHexString1(i&0x0f);
        }
        static String toHexString4 (int i) {
          return toHexString1((i>>12)&0x0f)
                 +toHexString1((i>>8)&0x0f)
                 +toHexString1((i>>4)&0x0f)
                 +toHexString1(i&0x0f);
        }
        public static void main (String[] args) throws CharacterCodingException {
          String encoding = "Cp964";
          Charset charset = Charset.forName(encoding);
          CharsetDecoder converter = charset.newDecoder();
          converter = converter.onMalformedInput(CodingErrorAction.REPORT);
          converter = converter.onUnmappableCharacter(CodingErrorAction.REPORT);
          for (int b = 0x80; b < 0x100; b++)
            if (!((b >= 0x80 && b <= 0x8d) || (b >= 0x90 && b <= 0x9f))) {
              ByteBuffer in = ByteBuffer.wrap(new byte[] { (byte)b });
              try {
                CharBuffer out = converter.decode(in);
                System.out.print("0x"+toHexString2(b)+" 0x");
                for (int j = 0; j < out.length(); j++) {
                  if (j > 0)
                    System.out.print(" 0x");
                  System.out.print(toHexString4(out.charAt(j)));
                }
                System.out.println();
              } catch (CharacterCodingException e) {
              }
            }
        }
      }

      ---------- END SOURCE ----------

            sherman Xueming Shen
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: