JDK-5058184 : Problems with encoders for IBM933, IBM949, IBM949C, IBM970
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-06-07
  • Updated: 2006-03-26
  • Resolved: 2006-03-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b78Fixed
Related Reports
Relates :  
Relates :  
Description
The following program demonstates problems with various encoders:

--------------------------------------------------
public class DebugEncoder {
    public static void main(String[] args) throws Exception {
	new String(new char[] {(char)Integer.parseInt(args[1], 16)})
	    .getBytes(args[0]);
    }
}
--------------------------------------------------

The invocation "java DebugEncoder IBM933 1100" simply hangs in an
infinite loop.

For exceptions generated using other charsets, see below:

$ java DebugEncoder IBM949 dc00
Exception in thread "main" java.lang.IllegalArgumentException
	at java.nio.Buffer.position(Buffer.java:218)
	at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:581)
	at java.lang.StringCoding$CharsetSE.encode(StringCoding.java:336)
	at java.lang.StringCoding.encode(StringCoding.java:372)
	at java.lang.String.getBytes(String.java:821)
	at DebugEncoder.main(DebugEncoder.java:3)
$ java DebugEncoder IBM949c dc00
Exception in thread "main" java.lang.IllegalArgumentException
	at java.nio.Buffer.position(Buffer.java:218)
	at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:581)
	at java.lang.StringCoding$CharsetSE.encode(StringCoding.java:336)
	at java.lang.StringCoding.encode(StringCoding.java:372)
	at java.lang.String.getBytes(String.java:821)
	at DebugEncoder.main(DebugEncoder.java:3)
$ java DebugEncoder IBM970 8e
Exception in thread "main" java.lang.IllegalArgumentException
	at java.nio.Buffer.position(Buffer.java:218)
	at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:581)
	at java.lang.StringCoding$CharsetSE.encode(StringCoding.java:336)
	at java.lang.StringCoding.encode(StringCoding.java:372)
	at java.lang.String.getBytes(String.java:821)
	at DebugEncoder.main(DebugEncoder.java:3)

###@###.### 2004-06-06

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon
14-06-2004

PUBLIC COMMENTS -
10-06-2004

EVALUATION Confirmed. I investigated these charsets, but their implementation is highly complex, so a fix may not be easy. The charsets are related by all apparently being used for Hangul, and so the bugs may be related. There is already a test case tailor-made for this bug, 5058133. When this bug is fixed, simply delete the lines excluding tests for the failing charsets in FindOneCharEncoderBugs.java. In fact, that is how these bugs were discovered. ###@###.### 2004-06-06
06-06-2004