Home  >  Article  >  Java  >  How to solve the unmappable characters in java encoding gbk

How to solve the unmappable characters in java encoding gbk

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-05-24 10:45:3321838browse

Solution: First use software to open the java file; then use the "ctrl a" key to select all the code in the file, and use the "ctrl c" key to copy the code; then click "Encoding" at the top of the page, and select Select "Use ansi encoding" in the list and use the "ctrl v" key to paste the code; finally save and run.

How to solve the unmappable characters in java encoding gbk

The operating environment of this tutorial: windows7 system, java10 version, Dell G3 computer.

When such an error occurs, it is usually because the code contains Chinese characters, and the Chinese characters in the comments are also counted. Because when using CMD to run a java program, the system's default encoding format is gbk. Codes containing Chinese characters are generally in UNICODE format, so it is easy to cause coding errors when running codes containing Chinese characters directly.

How to solve the unmappable characters in java encoding gbk

It is easy to solve the problem once you know the source of the problem. For those who use notpad, you can directly use the transcoding function that comes with the editor.

The encoding conversion position is in the Encoding column. Just convert the encoding to "Use ANSI format encoding".

How to solve the unmappable characters in java encoding gbk

But if we directly click "Use ANSI format encoding", we will find that the original Chinese characters are garbled, which is obviously not the effect we want.

How to solve the unmappable characters in java encoding gbk

The correct way is to copy all the source files first, then delete all the codes, and then set the encoding format to "Use ANSI format encoding". After setting Then paste the source file and save it. At this time, you will find that the encoding is in ANSI format.

How to solve the unmappable characters in java encoding gbk

After modification, we run it again and it works perfectly.

How to solve the unmappable characters in java encoding gbk

Related free learning recommendations: java basic tutorial

The above is the detailed content of How to solve the unmappable characters in java encoding gbk. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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