Solution to Chinese garbled characters in eclipse

Source: Internet
Author: User
The reason why eclipse encounters garbled characters is that the encoding rules selected by the eclipse editor are variable. Generally, the default is UTF-8 or GBK, when an external import project, if the project encoding method and eclipse set the encoding method is different, it will produce Chinese garbled problem, there are several other cases.

If the encoding method of the imported project conflicts with that of Eclipse, all Chinese characters in this project are garbled;

If the encoding methods of all projects conflict with those of the eclipse workspace, the Chinese characters in all projects may be garbled.

For the eclipse workspace, eclipse will save the settings you modified in the workspace settings file,

If you modify the encoding method of a single project, eclipse saves the encoding method in the. Setting file package of the project.

Therefore, there are two principles to avoid Chinese Garbled text:

(1) To avoid frequent changes to the workspace, it is recommended that the project be carried out in a workspace from the very beginning, in addition, it is best to set the encoding method of the workspace as the most frequently used or the project encoding method prescribed by the company, so that the project will use the encoding method of the workspace, avoid inconsistent codes;

(2) try to use the same encoding method for files of the same type to ensure that all files of the same type can use consistent encoding settings;

To solve Chinese Garbled text, you can set the following solutions:

(1) modify the workspace encoding method:

Window-> preferences-> General-> Workspace-> text file encoding
.

In others, select the desired encoding method and save it.

(2) modify the coding method of a single project:

Right-click the project and choose Properties From the shortcut menu"

.

Select Info (the first one) in the menu tree on the left of the new window, find text file encoding on the right, select "other", and select the encoding method in the drop-down box.
.

(3) modify the encoding method of a class of files:

If you want to set the JS file encoding method to UTF-8, you should

Window-> General-> content types

In content types, select JavaScript source file, select *. js in the file associations column, enter the UTF-8 in the default encoding column, click Update, and save.

(4) modify the encoding method of a single file: Right-click the file to be modified and select the last "properties" in the pop-up menu ", select Info (the first one) in the menu tree on the left of the new window, find text file encoding on the right, select "other", and select the encoding method in the drop-down box. This method is similar to modifying the engineering coding method.

PS: Another garbled problem encountered during the project is the font file of the operating system. In some cases, if the Chinese font of the system used by eclipse is damaged, it also causes the problem that Chinese characters cannot be displayed. Therefore, if the above settings cannot solve the problem, you should consider the problem of system font files.

Turn: http://www.eoeandroid.com/thread-114372-1-1.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.