Harmony
  1. Harmony
  2. HARMONY-137

CharsetDecoder should replace undefined bytes with replacement string

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Classlib
    • Labels:
      None

      Description

      Corresponding to cp1250 mapping table, 0x81 byte is undefined. See http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1250.TXT
      So, charset decoder should replace undefined bytes with default replacement, i.e. 0xFFFD.
      Testcase for reproducing this issue:

      import java.nio.charset.*;
      import java.nio.*;

      public class Harmony137 {
      public static void main(String[] args) throws Exception {
      ByteBuffer bb = ByteBuffer.allocate(5);
      bb.put((byte)0x81); bb.flip();
      Charset cp1250 = Charset.forName("cp1250");
      CharBuffer cb = cp1250.newDecoder().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE).decode(bb);
      if(cb.get(0)!=65533)

      { System.out.println("FAIL: expected 0xFFFD but result is: 0x"+Integer.toHexString(cb.get(0)).toUpperCase()); }

      }
      }

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Vladimir Strigun
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development