1. Influence of operating system language environment settings to the UFA application default coding method
In order to understand the mechanism for encoding the Java application, we must first understand the impact of the operating system's method for the UVM default encoding, so I made a
Env.java, used to print the local and system supported by the Properties and Systems supported by the JVM under different systems. The program is simple:
Import java.util. *;
Import java.text. *;
/ **
* Purpose:
* Display the default attribute of environment variables and JVM
* Enter: None
* Output:
* 1 Support Locale
* 2 JVM default properties
* /
PUBLIC CLASS ENV {
/ **
* Main entrance
* /
Public static void main (String [] args) {
System.out.println ("Hello, It's:" New Date ());
// Print Available Locales
Locale List [] = DateFormat.getavailableLocales ();
System.out.println ("====== System Available Locales: ========");
For (int I = 0; i System.out.println (List [i] .tostring () "/ t" list [i] .GetdisplayName ()); } // Print JVM Default Properties System.out.println ("====== System property ========"); System.getProperties (). List (system.out); } } What is most needed is the JVM's file.Encoding property. This property determines the default encoding / decoding method of JVM: thus affecting all byte streams in the application ==> Character flow decoding method, character stream ==> byte Coding method of stream. Conclusion 1: The default encoding method of JVM is determined by the "local language environment" setting of the system, and the type of operating system is independent. So when set to the same LOCALE, the default encoding method under Linux and Windows is no different (which can be considered to be the same as the same Western coding, only 255 Latin characters), So after the test 2 I only list the test results output to be set to en-en_, en_US, respectively. The following tests are the same as the output of the test after different areas and character sets in Windows. 2. The transformation process of the byte stream to the character stream during the input and output of Java passes this Hellounicode.java program, the demonstration "Hello World World Hello" string (16 characters) in different default system encoding mode Treatment effect. After each step of encoding / decoding, the BYTE value of each character, a Short value, and the Unicode section of each character, a SHORT value are printed. Some conclusions: