The reason for Eclipse's garbled behavior is that the Eclipse editor has chosen a variable encoding rule. Generally, the default is UTF-8 or GBK, when a project imported from the outside, if the project encoding and Eclipse settings in different encoding, will produce Chinese garbled problem, which there are several.
If the entire project is encoded in a way that is in conflict with the way eclipse is encoded, all Chinese in the project are garbled, and if the coding of all projects conflicts with the way the Eclipse workspace is encoded, then all the works in Chinese may be garbled. For the Eclipse workspace, Eclipse saves your settings in the workspace settings file and modifies the encoding of a single project so that eclipse will store the encoding in the project's. Setting package.
Therefore, to avoid the Chinese garbled problem has two principles:
(1) Avoid frequent change of working space, the best projects are done from the start in a workspace, and it is best to set up the working space coding method for the most commonly used or company-defined project coding, so that the project will use the coding method of the workspace, to avoid the occurrence of inconsistent coding;
(2) The same type of file to use the same encoding method, can ensure that the same type of files can use a consistent coding settings;
Solve the Chinese garbled problem can have the following setup scheme:
(1) Modify the coding mode of the working space:
Window->preferences->general->workspace->text file Encoding
Select the encoding you want in the others (if you don't enter it directly), and then save it.
(2) To modify the coding method of a single project:
Right-click the project and select the last "Properties" from the pop-up menu
Select Info (the first one) in the menu tree to the left of the Open new window, then locate the Text file encoding on the right, select "Other", and select the encoding you want in the Drop-down box (if it is not entered directly).
(3) Modify the encoding of a class of files:
If you want to set the JS file encoding to UTF-8, you should
Window->general->content Types
Select JavaScript Source file in the content types, select *.js in the File associations column, and then enter UTF-8 in the default encoding column, click Update to save it.
(4) Modify the encoding of a single file: Right-click the file to be modified, select the last "Properties" in the pop-up menu, select Info in the menu tree to the left of the Open new window (that is, the first one), and then locate the Text file encoding on the right-hand side and select "Other , select the encoding you want in the Drop-down box (if you don't enter it directly). Similar to the method of modifying engineering coding methods.
PS: Another garbled problem encountered during the project is due to the font file problem of the operating system, and in some cases, the Chinese fonts used by Eclipse can cause problems that Chinese cannot display if they are damaged. Therefore, if the above settings can not solve the problem, you should consider the problem of the system font files.
Author: csdn Blog tfy1332
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/