Solve Chinese garbled characters in eclipse

Source: Internet
Author: User

When you use eclipse to edit files, Chinese characters are often garbled or files with Chinese characters cannot be saved. Eclipse provides flexible options for setting file encoding formats. We can solve the garbled problem by setting encoding formats. In eclipse, you can set the encoding formats from several levels: workspace, project, content type, and file.
This article takes eclipse 3.3 (English) as an example to describe:
1. Set the encoding format of the Workspace:
Windows-> preferences... open the "Preferences" window, click the left-side navigation tree to general-> workspace, and find the "text file encoding" option setting in the right-side view. One is default ), select (other) from the drop-down list ). The default encoding method of eclipse workspace is the operating system encoding format, which is related to the operating system settings. In addition, we can select the other single-choice button, then select the desired encoding format (GBK, ISO-8859-1, UTF-16, UFT-16 etc.) from the drop-down list on the right of the button .).
2. Set the project encoding format:
The project created in Workspace inherits the workspace encoding settings by default. You can also change the encoding format of a project separately. Right-click the project, select properties, and open the project property settings window. In the left-side navigation tree, select resource, and find "text file encoding" in the right-side view. The two formats are used to set the project encoding format, the "inherited from container (XXX)" is selected by default (Note: XXX is the encoding set for workspace). You can also select another encoding format, which is the same as that for workspace.
3. Set the encoding format of content type:
Sometimes we want to keep some types of files in the workspace in the same encoding format. This requires the content type setting. The specific method is as follows: Windows-> preferences... open the "Preferences" window, select general-> content types in the left navigation tree, select text-> JAVA source file in the right-side view, and have the default encoding input box at the bottom, manually enter the encoding format and click the update button to make the setting take effect (remember !). Pay attention to the following two points:
A. This setting enables identical encoding formats for files of the same type under all projects in the workspace. Changing the encoding settings of projects does not affect the encoding settings of file types in the project;
B. default encoding is manually entered. The entered encoding name must be accurate. Otherwise, the unsupported character encoding will be displayed when you open this type of file.
4. Set the file encoding format:
We can also set the encoding format for a file separately, either by setting the encoding grid in the file (for example, 'charset = UTF-8 ') or by setting the file properties. Right-click a file and select properties. The file attribute Setting dialog box is displayed. Select resource in the navigation tree on the right. In the view on the right, select "text file encoding" to set the encoding format of the file.

Reference:
1. http://bbs.idcbbs.net/thread-5176-1-1.html
2. http://topic.csdn.net/u/20070613/23/6C6F6C66-B962-4E88-A41D-F5349C7594F7.html
3. http://e-ant.javaeye.com/blog/177579

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.