Myeclipse garbled code modification (encoding format modification)

Source: Internet
Author: User

1. Set the default encoding format for creating common files, that is, the file storage format.
When you do not set myeclipse, the file encoding is saved by default, which is generally consistent with that of the simplified Chinese operating system (such as Windows2000 and WindowsXP), that is, GBK.
In a simplified Chinese system, ANSI encoding represents GBK encoding; in a Japanese operating system, ANSI encoding represents JIS encoding.
Window --> preferences --> General --> content types
Expand each subitem in the window on the right and enter the encoding format in sequence, as shown in "UTF-8" click "Update" to set up.
For example: in the above settings, set JSP default encoding format for "UTF-8", then the new JSP file, are saved in the "UTF-8" format.
Similarly, if you set the default Java encoding format to "UTF-8", then the newly created java files will be saved in the "UTF-8" format.
Set the default HTML encoding format to "UTF-8", then the HTML files created later are saved in "UTF-8" format.
The file storage encoding format is set above. The default open mode (decoding mode) will be the same as the Save encoding format.

2. Set the default encoding format for creating other files, that is, the file storage format.
In the first setting, only the encoding format of common file types is set. If you create a new file without a suffix, that is, the file type is not specified, myeclipse cannot determine the encoding type to use.

Save the format, and use the default file save encoding format GBK to save. The encoding format is saved by default and can be modified as follows:
Window --> preferences --> General --> workspace in the right text file encoding-> other select UTF-8

3. view the encoding format of a single file (that is, the encoding format used to open the file. This method does not change the file encoding format, but only tells myeclipse which encoding format is used for decoding.
Right-click the file to be viewed, for example, test. Java, and choose Properties> resource from the right-side text file encoding> Other to modify the file.
For example, you set * in "1 *. the Java file encoding format is "UTF-8", then you open the file with the extension name of Java, the default will be in the "UTF-8" format for decoding. If someone gives you

The compiled Java file is saved in GBK encoding, so garbled characters are displayed when you open the file. Right-click the file and choose Properties> resource in text file on the right.

Encoding-> Other-> GBK to display the content normally.

4. Specify the data encoding format of the page content when writing a file in myeclipse, such as HTML, the Information encoding format entered by the user before submitting a form in the JSP webpage, and the parameter encoding format in the XML file.
It mainly refers to the encoding format of the transmitted data for the notification browser or server.
Window --> preferences --> myeclipse --> files and editors --> select subitem --> Encoding
For example: Select UTF-8,
When you create a JSP file, contenttype = "text/html; charset = UTF-8" pageencoding = "UTF-8" is automatically generated, no need to manually change it each time.
HTTP-equiv = "Content-Type" content = "text/html; charset = UTF-8"
When creating an XML file, <? XML version = "1.0" encoding = "UTF-8"?>

The above is my summary. If it is incorrect, please point it out. The problem is as follows:
1. If someone else gives a project, the encoding format is GBK, I use the encoding format for UTF-8, import this project, the display garbled, what need to be modified?
I want to know the most useful method that must be modified. If all of the above changes are made in turn, they can be displayed normally. However, after the modification, Chinese characters may be garbled again when you view your code.
In fact, this problem is, how to make two projects use different encoding (such as UTF-8 and GBK), and can be viewed normally, no garbled.

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.