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

EUC_JP_LINUX sets source position incorrectly when encountering JIS0212 character

XMLWordPrintable

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

      When decoding using EUC_JP_LINUX from a direct byte buffer
      containing a 0212 character with error action set to REPLACE,
      the source position is incorrectly advanced, causing subsequent
      input bytes to be ignored.

      Here's a test fragment:

          private static void equal(CharBuffer b1, CharBuffer b2) {
      equal(b1.position(), b2.position());
      equal(b1.limit(), b2.limit());
      System.out.printf("positions=%d %d%n", b1.position(), b2.position());
      System.out.printf("limits=%d %d%n", b1.limit(), b2.limit());
      for (int i = b1.position(); i < b1.limit(); i++)
      equal((int)b1.get(i), (int)b2.get(i));
          }

          private static void realMain(String[] args) throws Throwable {
      List<ByteBuffer> bbs = Arrays.asList(
      ByteBuffer.allocate(10),
      ByteBuffer.allocateDirect(10));
      List<CharBuffer> cbs = new ArrayList<CharBuffer>();

      for (ByteBuffer bb : bbs) {
      bb.put(new byte[]{ (byte)0x8f, 0x01, 0x02,
      (byte)0xa1, (byte)0xc0,
      0x02, 0x03});
      bb.flip();
      CharsetDecoder decoder = Charset.forName("EUC_JP_LINUX").newDecoder();
      decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);
      CharBuffer cb = decoder.decode(bb);
      cbs.add(cb);
      }
      equal(cbs.get(0), cbs.get(1));
          }

            martin Martin Buchholz
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: