In the use of eclipse + myeclipse development, many file encoding is the default ISO-8859-1, does not support Chinese (such as commonly used JSP ). In this way, we need to manually change the encoding for each file creation. In fact, we can set the default encoding for the file, so we do not need to change the encoding every time we create a file later.
UTF-8
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... open the "Preferences" dialog box, left navigation tree, navigate to general-> workspace, right text file encoding, select other, change to UTF-8, text file encoding in its properties dialog box is the UTF-8.
2. Windows-> preferences... open the "Preferences" dialog box, navigation tree on the left, navigate to general-> content types, context types tree on the right, open each subitem in text, and enter "UTF-8 ", click Update!
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. Window --> preference --> myeclipse --> files and editors, change "encoding" for each subitem to "ISO 10645/Unicode (UTF-8)", click Apply!
4. After the three steps above, the new Java file is UTF-8 encoding, eclipse compilation, running, debugging is no problem, but the RCP application product output, or plug-in output, there is always an error. Either the compilation fails (compile must be re-compiled during 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 UTF-8 encoding format, if not all, you can refer
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 the 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.
Myeclipse encoding settings
My myeclipse installation after the default encoding is gb18030, people outside is generally recommended to use UTF-8. If garbled characters are found after the project is imported, the encoding settings are incorrect.
Global encoding settings: toolbar --> window --> preferences --> General --> workspace --> text file encoding to set the appropriate encoding.
Local encoding settings: Right-click the source code and choose --> General --> editors --> test editors --> spelling --> encoding. Here we set the encoding of a single file.
we recommend that you use global encoding settings.