The default encoding is selected by the JRE based on the host operating system and its locale. For example, in the US locale on Windows, windows-1252 is used. In the Simplified Chinese locale on Solaris, GB2312, GBK, GB18030, or UTF-8 can be the default encoding, depending on the selection made when logging into Solaris.
The default encoding is significant because the JRE commonly exchanges text with the host operating system in the default encoding. The default encoding has to match the encoding used by the host operating system to ensure correct interaction.
An application can determine the default encoding by calling the Charset.defaultCharset
method, available since J2SE 5.0. In older versions of the Java platform, you can use the expression
(new OutputStreamWriter(new ByteArrayOutputStream())).getEncoding()
No comments:
Post a Comment