sun.nio.cs.map
- Organization of this page
Format
sun.nio.cs.map=Windows-31J/Shift_JIS
Description
This property specifies whether to equate the encoding names shift_jis, csshiftjis, ms_kanji, and x-sjis with MS932.
In JDK 1.4.0, the character encoding aliases shift_jis, csshiftjis, ms_kanji, and x-sjis were aliases of MS932. However, from JDK 1.4.2 onwards, they were changed to aliases of SJIS. If you have a program in which shift_jis, csshiftjis, ms_kanji, or x-sjis is used as an alias of MS932 and run it with JDK 1.4.2 or later, text might be garbled.
To handle shift_jis, csshiftjis, ms_kanji, and x-sjis as aliases of MS932 in the same way as with JDK 1.4.0, specify Windows-31J/Shift_JIS for the sun.nio.cs.map property.
Example:
import java.io.*;
class encode_Shift_JIS {
public static void main( String arg[] ) {
try {
String string_data = "
";
byte[] data = string_data.getBytes();
InputStreamReader isr =
new InputStreamReader(
new ByteArrayInputStream( data ), "shift_jis");
char[] read_data = new char[6];
isr.read( read_data, 0, 6 );
System.out.println(new String(read_data));
}
catch ( Exception e ) {
e.printStackTrace();
}
}
}When the preceding program is executed with JDK 1.4.0, text is not garbled because shift_jis is handled as an alias of MS932. However, if the program is executed with JDK 1.4.2, text is garbled as follows:
java encode_Shift_JIS
??@?To avoid such garbled text, specify Windows-31J/Shift_JIS for the sun.nio.cs.map property when executing the program.
Examples of specification
If you set this property on a J2EE server, specify the following entry in the usrconf.cfg file:
add.jvm.arg=-Dsun.nio.cs.map=Windows-31J/Shift_JIS
For details about how to specify settings in the usrconf.cfg file in a specific environment such as a J2EE server, see 2.2.2 usrconf.cfg (Option definition file for J2EE servers).