Microsoft KB Archive/260818

= FIX: JIS Japanese Character Encoding Throws Exception =

Article ID: 260818

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Java Virtual Machine, when used with:
 * Microsoft Windows 2000 Standard Edition

-



This article was previously published under Q260818



SYMPTOMS
When you use &quot;JIS&quot; Japanese character encoding on a 3200-series build of the Microsoft virtual machine (Microsoft VM), you might encounter an UnsupportedEncodingException when you use certain aliases. Note that you might have successfully used these aliases on earlier versions of the Microsoft VM. See the &quot;More Information&quot; section of this article for the specific aliases that cause this exception.



CAUSE
The UnsupportedEncodingException is not entirely accurate because the encoding itself is supported. However, some of the previously supported aliases are not. This is due to some missing entries in a table that maps aliases to encoder classes.



RESOLUTION
To work around this problem, for any JIS encoding aliases that fail specify &quot;JIS&quot; explicitly or an alias other than those listed in the &quot;More Information&quot; section of this article.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug has been verified to occur in the 3200 series of the Microsoft VM.

This problem was corrected in Windows 2000 Service Pack 1.



Steps to Reproduce Behavior

 * 1) Use the code sample provided in this section and change the second parameter in the call to the string constructor to equal one of the missing aliases listed after the code.
 * 2) Compile and run the code.

If the alias is missing from the table, you will get an UnsupportedCodingException.
 * 1) To prove that the encoding is supported, change the second parameter back to &quot;JIS&quot;, and then recompile and run the code.

import java.io.UnsupportedEncodingException; public class EncodingTest { public static void main (String[] args) throws Exception {   try {     byte[] data = {(byte)'s',(byte)'t',(byte)'r',(byte)'i',(byte)'n',(byte)'g'}; String str = new String(data, &quot;JIS&quot;); }   catch (UnsupportedEncodingException ex) {     ex.printStackTrace; System.in.read; } } } The following are the missing entries in the alias mapping table:   &quot;iso-2022-jp&quot;     --> &quot;JIS&quot; &quot;csiso2022jp&quot;    --> &quot;JIS&quot; &quot;jis_encoding&quot;   --> &quot;JIS&quot; &quot;csjisencoding&quot;  --> &quot;JIS&quot; Also note that the following aliases in builds later than the 3200 series will be mapped to the MS932 encoding rather than &quot;SJIS&quot;.   &quot;shift_jis&quot;       --> &quot;MS932&quot; &quot;ms_kanji&quot;       --> &quot;MS932&quot; &quot;csshiftjis&quot;     --> &quot;MS932&quot; &quot;windows-31j&quot;    --> &quot;MS932&quot; &quot;cswindows31j&quot;   --> &quot;MS932&quot;

