< turn >
Since the JDK is an international version, at compile time, if we do not specify the encoding format of our Java source program with the-encoding parameter, Then Javac.exe first get our operating system by default encoding format, that is, when compiling Java programs, if we do not specify the source program file encoding format, the JDK first obtains the operating system's file.encoding parameter (it is the operating system default encoding format, such as Win2K, which has a value of GBK), then the JDK translates our Java source program into memory from the file.encoding encoded format into the Java internal default Unicode format. Javac then compiles the converted Unicode file into a. class file, at which point the. class file is Unicode encoded, which is temporarily placed in memory, followed by The JDK saves this compiled, Unicode-encoded class file into our operating system to form the. class file that we see. For us, the. class file that we finally get is the class file that the content is saved in Unicode encoded format, which contains the Chinese string inside our source program, except that it has been converted to Unicode format by file.encoding format. When we compile without setting, the equivalent of using parameters: Javac-encoding GBK Xx.java, of course, there will be incompatibilities.
The workaround is: You should use the-encoding parameter to indicate the encoding: javac-encoding UTF-8 Xx.java, this is not a warning, the operation is also correct in JCreator 4 settings: Menu: Configure--Options-- > JDK Tools--Compiler, check <default>, and then select Edit,parameters inside, first add:-encoding UTF-8.
How do I view the operating system character set?
Under Windows platform, enter the DOS window, type: CHCP
You can get the code page information for the operating system, and you can view the detailed character set information for the code page from the Language Options in Control Panel.
For example:
My Activity code page is: 936, and it has an encoding format of GBK.
Problems with Java encoding