Turn from
http://hsj69106.blog.51cto.com/1017401/595598/
With eclipse editing files often garbled in Chinese or the file has the problem of Chinese can not be saved, Eclipse provides the flexibility to set the file encoding format options, we can set the encoding format to solve garbled problems. In eclipse you can set the encoding format from several levels: Workspace, Project, Content Type, File
This article takes Eclipse 3.3 (English) as an example to illustrate:
1. Set the encoding format of the workspace:
Windows->preferences ... Open the Preferences window, click the left navigation tree to General->workspace, find the "Text file encoding" option setting in the right view, one is default, and the other is select from the drop-down list (other). The default encoding for Eclipse workspace is the encoding format of the operating system, which is related to the settings of the operating system, and we can select the other radio button and select the desired encoding format from the drop-down list on the right side of the button (GBK, iso-8859-1, UTF-16, UFT-16 etc.).
2. Set the encoding format for project:
New projects in workspace inherit the encoding settings of workspace by default, and we can change the encoding format of an item individually. Right click on Project, select Properties, open Project Properties Settings window, left navigation tree Select Resource, find "Text file encoding" in the right view, two encoding formats for the project, the default is "inherited from Container (XXX) "(Note: XXX for workspace set encoding), we can also choose other encoding format, set up in the same way as workspace.
3. Set the encoding format for the content type:
Sometimes we want to keep the whole workspace of some type of file in the same encoding format, which requires the content type setting to achieve the goal, as follows: Windows->preferences ... Open the Preferences window, select General->content Types on the left navigation tree, select Text->java Source File in the right view, and the default encoding input box at the bottom, enter the encoding format manually, Click the Update button to make the settings effective (remember!) )。 There are two points to note:
A. This setting makes the same type of files under All projects workspace the same encoding format, changing the encoding settings of the project does not affect the encoding settings of the file types in the project;
B. The Default Encoding is entered manually, and the encoded name entered is accurate, otherwise the unsupported Character Encoding is displayed when this type of file is opened.
4. Set the encoding format for file:
We can also set the encoding format of a file individually, either by setting the encoding grid in the file (for example: ' Charset=utf-8 '), or by setting the file properties. Right click on a file, select Properties, open the File Properties Settings dialog box, the right navigation tree Select Resource, in the right side of the view through "Text file encoding" Select the encoding format of the file.
Solve Eclipse Chinese garbled