bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/30693] New: CharsetDecoder.decode incorrectly sets buffer


From: jeroen at frijters dot net
Subject: [Bug classpath/30693] New: CharsetDecoder.decode incorrectly sets buffer position when it encounters unmappable characters
Date: 3 Feb 2007 16:01:01 -0000

This code throws an exception:

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

class bug
{
  public static void main(String[] args) throws Exception
  {
    byte[] data = new byte[] { (byte)0, (byte)129 };
    int offset = 0;
    int count = 2;
    CharsetDecoder csd = Charset.forName("Windows-1252").newDecoder();
    csd.onUnmappableCharacter(CodingErrorAction.REPLACE);
    CharBuffer out = CharBuffer.allocate(count * (int)csd.maxCharsPerByte());
    csd.decode(ByteBuffer.wrap(data, offset, count), out, true);
    csd.flush(out);
    System.out.println(out.flip().toString());
  }
}


-- 
           Summary: CharsetDecoder.decode incorrectly sets buffer position
                    when it encounters unmappable characters
           Product: classpath
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: classpath
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jeroen at frijters dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30693





reply via email to

[Prev in Thread] Current Thread [Next in Thread]