Home > Java > javaTutorial > body text

How to quickly solve the Chinese garbled problem in eclipse

little bottle
Release: 2019-04-10 10:56:01
forward
26124 people have browsed it

The Chinese garbled characters in eclipse are caused by the character encoding not matching the default encoding. There are many ways to solve it. You don’t need to install any plug-ins to solve it. . For different situations, different solutions need to be used. Here are some cases to explain how to solve the problem of garbled characters. The main idea to solve the problem of garbled characters is to set a correct and appropriate encoding. If you don’t know the original encoding of the target file, you can make some attempts. Usually, you can try GBK and UTF-8.

method 1

Set the character encoding of a single file to solve the problem of garbled characters in a single file

Sometimes the encoding of a single file accidentally copied is inconsistent with the default encoding of your workspace, resulting in a single garbled character. Solution: In the Pakcage Explorer or Project Explorer view, right-click the file ->Select "Properties"->"Text file encoding"->Set the corresponding encoding for the "Other" item. (It should be noted that if the copied file displays normally in eclipse, but the encoding is inconsistent with other files, if you want to unify the encoding, you need to remember to copy the file content first, and then set it up before setting the encoding. Encoding, and then paste the copied content into the file after the encoding has been modified, so that the code will not be garbled; once the content of the encoded file is modified, the code will be garbled).



  • ##2
  • Set the characters of the third-party jar package Encoding to solve the garbled problem of the entire jar

    The encoding problem of third-party jar packages may be the most common problem. The solution is similar to that of a single file. In the Pakcage Explorer or Project Explorer view, right-click the third-party jar package – >Select "Properties"–>Set the corresponding encoding for the "Encoding" item.



  • ##3

  • Set the characters for different types of files respectively Encoding
  • Sometimes in order to unify the encoding of all projects, it may be necessary to set the character encoding of various types of files in advance, for example: set all jar classes to GBK encoding, set all xml to UTF-8 encoding, etc. At this time, you need to set different encodings for different types of files in a targeted manner. The steps are as follows: Windows–>Perferences–>General–>Content Types–>Select the file type–>Set the “Default encoding” item.



  • ##4

  • Set the default character encoding for text files in the entire workspace
    Often workspaces have a default character encoding. If most or all of your projects are in another encoding, then you can reset a default character encoding. There is no need to set the encoding for subsequent new projects. The steps are as follows: Windows–>Perferences–>General–>Workspace–>Test file encoding–>Set the corresponding encoding for “Other:”.


  • [Recommended course: Java video tutorial]

The above is the detailed content of How to quickly solve the Chinese garbled problem in eclipse. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template