myeclipse set character encoding

<div class="iteye-blog-content-contain" style="font-size: 14px">

1. Set the default encoding format for newly created common types of files, that is, the format in which the files are saved.
When MyEclipse is not set, the encoding of the file to be saved by default is generally the same as the encoding of the Simplified Chinese operating system (such as windows2000, windowsXP), that is, GBK.
Under the Simplified Chinese system, ANSI encoding represents GBK encoding; under Japanese operating system, ANSI encoding represents JIS encoding.
Window-->Preferences-->General -->content Types
expand each sub-item in the right window, Enter the encoding format in turn, such as "UTF-8" and click "update" to set it.
For example: In the above settings, set the default encoding format of jsp to "UTF-8", then the newly created jsp files will be saved in "UTF-8" format.
Also set the java default encoding format to "UTF-8", then the newly created java files will be saved in "UTF-8" format.
Set the html default encoding format to "UTF-8", then the newly created html files will be saved in "UTF-8" format.
The above sets the save encoding format of the file, and the default opening method (decoding method) will be the same as the save encoding format.  



2. Set the default encoding format of other new files, that is, the file saving format.
    In the first setting, only the encoding format of common file types is set. If you create a new file without a suffix name, that is, without specifying the file type, MyEclipse cannot determine which encoding format to use for saving, so it uses the operating system default file save encoding format GBK to save. This default save encoding format can be modified as follows:
window-->preferences-->general-->workspace on the right side Text file encoding ->Other select UTF-8



Third, single file view encoding format (that is, the encoding format used to open the file) change.

This method does not change the encoding format of the file, it just tells MyEclipse which encoding format to use for decoding.
On the file to be viewed, for example, right-click on the file Test.java --> Properties-->Resource on the right side Text file encoding ->Other , you can modify it.
For example, if you set the encoding format of the *.java file in "One" to "UTF-8", then when you open a file with the suffix java, it will be decoded in "UTF-8" format by default. If someone gave you a written java file, but he saved it with GBK encoding, then when you open it now, it will display garbled characters. Right-click on this file-->Properties-->Resource on the right side Text file encoding ->Other ->GBK, you can display the contents normally.



4. The default encoding settings of a single project workspace.

Right-click on the project-->Properties-->Resource on the right side Text file encoding ->Other, you can modify it.



5. Specify the page content data encoding format when MyEclipse writes the file (in fact, it is the default setting of the parameter), such as html, Or before submitting the form in the jsp webpage, the encoding format of the information input by the user, the parameter encoding format in the configuration file xml, etc.
Mainly to notify the browser or server, the encoding format of the transmitted data. Tell the browser what encoding to use to parse html or JSP files.
window-->Preferences-->MyEclipse-->Files and Editors-->Select sub-items-->Encoding
For example: select UTF-8,
when creating a new jsp file, contentType="text/html; charset=UTF-8 " pageEncoding="UTF-8" will be automatically generated, no need to manually change it every time.
When creating a new html file, http-equiv="Content-Type" content="text/html; charset=UTF-8"
When creating a new xml file, <?xml version="1.0" encoding="UTF-8"? >


6. The encoding used in the console display of eclipse is the character encoding format set by the workspace (that is, the encoding format set in "2" above).




The above is my own summary, if I am wrong, please point out. The questions are as follows
1. If someone else gave a project, the encoding format is GBK, and the encoding format I use is UTF-8. After importing this project, it displays garbled characters, what modifications need to be made?
I would like to know where "must have to be modified". If I change all the above points in sequence, the imported project encoded with GBK can be displayed normally. However, after the change, when viewing the code of the project encoded in UTF-8, Chinese garbled characters will appear again.
In fact, the question is, how to make the two projects use different encodings (such as UTF-8 and GBK), and both can be viewed normally without garbled characters.

2. Open the written java code, right click-->General--> Editors-->Test Editors-->Spelling-->Encoding What is the purpose of this? ? ?
This is the same as window-->preferences-->general-->General-->Editors-->Test Editors-->Spelling-->Encoding modification effect, this is a global modification.
This setting inherits the global workspace encoding format by default, which is the encoding format set in "2" above.
</div>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326082346&siteId=291194637