Home > Development Tools > notepad > notepad++java code encoding gbk's unmappable characters

notepad++java code encoding gbk's unmappable characters

(*-*)浩
Release: 2019-08-21 16:44:42
Original
2905 people have browsed it

notepad++java code encoding gbk's unmappable characters

After using the notepad editor to write the java code, and then using javac to compile it, such an error occurs! (Recommended learning: notepad )

The code is as follows:

notepad++java code encoding gbks unmappable characters

The error is as follows Picture:

notepad++java code encoding gbks unmappable characters

Error reason:

Since the JDK is an international version, when compiling, if we do not Use the -encoding parameter to specify the encoding format of our JAVA source program. Then javac.exe will first obtain the encoding format used by our operating system by default. That is, when compiling a java program, if we do not specify the encoding format of the source program file, JDK will first Obtain the file.encoding parameter of the operating system (it saves the default encoding format of the operating system, such as WIN2k, its value is GBK), and then JDK converts our java source program from the file.encoding encoding format to the JAVA internal default UNICODE format into memory.

Then, javac compiles the converted unicode format file into a .class class file. At this time, the .class file is UNICODE encoded, and it is temporarily placed in the memory. Then, JDK converts this file into a UNICODE file. The encoded and compiled class file is saved to our operating system to form the .class file we see.

For us, the .class file we finally obtained is a class file whose content is saved in UNICODE encoding format. It contains the Chinese string in our source program, but at this time it has been passed through file. The encoding format is converted to UNICODE format.

When we compile without setting, it is equivalent to using the parameters: javac -encoding gbk XX.java. Of course, incompatibility will occur.

Solution:

Menu: Settings→Preferences→New, select the encoding method as ANSI.

notepad++java code encoding gbks unmappable characters

The above is the detailed content of notepad++java code encoding gbk's unmappable characters. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template