How to Set encoding in eclipse

Source: Internet
Author: User

If you want to make plug-in development applications have better international support, to maximize support for Chinese output, it is best to make java files use UTF-8 encoding. However, the default character encoding of the eclipse workspace is the default encoding of the operating system, while the default encoding of the simplified Chinese operating system (Windows XP, Windows 2000 Simplified Chinese) is gb18030, the project code created in this workspace is gb18030, And the Java file created in the project is also gb18030. If you want to make the new build project, java files directly make the UTF-8, you need to do the following:

1. Windows-> preferences-> General-> workspace, right text file encoding, select other, change to UTF-8, the text file encoding in the Properties dialog box of the newly created Project is the UTF-8.

2. Windows-> preferences-> General-> content types, context types tree on the right, click on text, select Java source file, and enter the UTF-8 in the default encoding input box below, click Update to set the Java file encoding to UTF-8. Other files related to Java application development, such as properties and XML, have been specified by the eclipse default, respectively for the ISO8859-1, UTF-8, such as the development of the need to change the encoding format can be specified here.

3. After the above two steps, the new Java file is UTF-8 encoding, eclipse compilation, running, debugging is no problem, however, when the product output of the RCP application or the plug-in output, there is always an error, either it cannot be compiled (compile must be re-compiled during the output), or the Chinese characters are garbled during the running of the output plug-in. Now you need to add a line in the build. Properties of the RCP application, or plug-in Plug-in project, javacdefaultencoding .. = UTF-8. Let the output compile know the UTF-8 encoding for the Java source file. This setting needs to ensure that all Java source files are in UTF-8 encoding format, if not all, see eclipse help (plug-in development environment guide> reference> feature and plug-in build configuration), it is recommended that all Java source files are UTF-8 encoding.
If plug-in development, RCP application development based on other encoding, such as gb18030, want to convert to UTF-8, first, do the above work; then through the search encoding conversion tool, for example, based on the iconv batch conversion tool, convert the original encoding to UTF-8 encoding, note that only the conversion of Java source files, other types of files may already be more appropriate encoding; change text file encoding from the original project property to the UTF-8.

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.