Bug 30693 - CharsetDecoder.decode incorrectly sets buffer position when it encounters unmappable characters
Summary: CharsetDecoder.decode incorrectly sets buffer position when it encounters unm...
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-03 16:01 UTC by Jeroen Frijters
Modified: 2007-02-04 09:59 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeroen Frijters 2007-02-03 16:01:01 UTC
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());
  }
}
Comment 1 Jeroen Frijters 2007-02-04 09:59:29 UTC
Fixed.