-
Bug
-
Resolution: Duplicate
-
P1
-
None
-
1.4.2_04
-
None
-
generic
-
generic
@ Executing the following code in the BeanShell running on the JVM:
@ .
@ bsh% import java.nio.charset.Charset;
@ bsh% final String CS_JIS0212 = "JIS0212";
@ bsh% System.out.println(Charset.isSupported(CS_JIS0212) ? "Issupported"
@ : "Not
supported");
@ bsh% Charset cs = Charset.forName(CS_JIS0212);
@ bsh% System.out.println(cs.canEncode() ? "Can encode" : "Cannot encode");
@ .
@ Gives the following output:
@ .
@ bsh % Is supported
@ bsh % Can encode
@ .
@ However,
@ .
@ bsh% String.valueOf('a').getBytes("JIS0212");
@ .
@ gives:
@ .
@ java.lang.IllegalArgumentException: Illegal replacement
@ at
@ java.nio.charset.CharsetEncoder.replaceWith(CharsetEncoder.java:262)
@ at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:180)
@ at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:203)
@ at
sun.nio.cs.ext.DoubleByteEncoder.<init>(DoubleByteEncoder.java:31)
@ at sun.nio.cs.ext.JIS_X_0212$Encoder.<init>(JIS_X_0212.java:63)
@ at sun.nio.cs.ext.JIS_X_0212.newEncoder(JIS_X_0212.java:34)
@ at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:317)
@ at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:308)
@ at java.lang.StringCoding.encode(StringCoding.java:365)
@ at java.lang.String.getBytes(String.java:573)
@ .
Or a simpler test case:
@Using the JDK1.4.2_04 JVM running on Windows 2000 (SP4), executing the
@ following line of code:
@ .
@ "a".getBytes("JIS0212");
@ .
@ results in the following exception:
@ .
@ java.lang.IllegalArgumentException: Illegal replacement
@ at
@ java.nio.charset.CharsetEncoder.replaceWith(CharsetEncoder.java:262)
@ at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:180)
@ at java.nio.charset.CharsetEncoder.<init>(CharsetEncoder.java:203)
@ at
sun.nio.cs.ext.DoubleByteEncoder.<init>(DoubleByteEncoder.java:31)
@ at sun.nio.cs.ext.JIS_X_0212$Encoder.<init>(JIS_X_0212.java:63)
@ at sun.nio.cs.ext.JIS_X_0212.newEncoder(JIS_X_0212.java:34)
@ at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:317)
@ at java.lang.StringCoding$CharsetSE.<init>(StringCoding.java:308)
@ at java.lang.StringCoding.encode(StringCoding.java:365)
@ at java.lang.String.getBytes(String.java:573)
@ .
@ Using JIS0208 also fails in a similar way.
- duplicates
-
JDK-4991519 Encoding Unicode to JIS0208 Throw exception
-
- Resolved
-
- relates to
-
JDK-4904370 JDK 1.4 and the JIS0208 character set encoding
-
- Resolved
-