Go: How encoding is set in eclipse

Source: Internet
Author: User

Source: http://blog.csdn.net/jianw2007/article/details/3930915

If you want to enable plug-in development applications to have better internationalization support, to maximize the support of Chinese output, it is best to make Java files using UTF-8 encoding. However, the default encoding for theEclipse Workspace (workspace) is the default encoding for the operating system, and the default code for the Simplified Chinese operating system (Windows XP, Windows 2000 Simplified Chinese) is GB18030, The engineering code established in this workspace is GB18030, and the Java file created in the project is also GB18030. If you want to make the new project, Java files directly to UTF-8, you need to do the following:

1. Windows->preferences ... Open the Preferences dialog, navigate to the left navigation tree, navigate to General->workspace, right text file encoding, select Other, change to UTF-8, and later create a new project in its Properties dialog box, text file Encoding is the UTF-8.

2. Windows->preferences ... Open the Preferences dialog box, left navigation tree, navigate to general->content Types, right context Types tree, click Text, select Java Source File, under Default Enter UTF-8 in the Encoding input box and click Update to set the Java file encoding to UTF-8. Other Java application development related files such as: properties, XML, etc. have been specified by the eclipse default, respectively, 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 compile, run, debug all no problem, but do rcp application product output, or plug-in output, always error, or can not compile through (the output to re-compile), Or the output of the plug-in runtime Chinese display garbled. At this time need to re-rcp application, or plug-in plugin project Build.properties add a line, javacdefaultencoding. = UTF-8. Let the output compile when you know the Java source file UTF-8 encoded. This setting needs to ensure that all Java source files are UTF-8 encoded, and if not all, refer to the 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 encoded.


If plug-in development, RCP application development originally based on other coding, such as GB18030, want to convert to UTF-8, then first, do the above work, and then by looking for the encoding conversion tool, such as Iconv-based batch conversion tool, the original code to convert to UTF-8 encoding, note that only the Java source files are converted, Other types of files may already be the appropriate encoding, and the Text file encoding in the original project attribute, changed from the original code to UTF-8.

Recommended transcoding Tool Dojo Chinese garbled & recommend a transcoding tool

Previous Java projects have been using GBK encoding, and the dojo version is 1.1.1,

Dojo Chinese garbled problem is really difficult to solve. Sent from the server to the client response.setcontenttype ("text/html; Charset=utf-8 ") will be able to solve garbled characters. From the client to the server with the parameter value is not trouble, the page to pass the parameter value encoded encodeURI (str), in the Aciton decoding Java.net.URLDecoder.decode ( Request.getparameter ("str"), "UTF-8"). But if it is to put the whole page form into the background is puzzled, and finally decided to change the entire project code to UTF-8, which will have to transcode all the previous files, of course, with UE or Notepad to open save As for UTF8 is no problem, but so many files do seem to be too silly, you can write all kinds of transcoding, but online already have ready and packaged into small tools, as long as simple operation is OK, very convenient.

Recommended transcoding tool:ultracodingswitch-v1.0 (Search can find http://www.duote.com/soft/12486.html) have a friend in need, you can also contact me Send it directly to you. More than 470 K size, free of installation, can batch files and folders, easy to use, on the code asked to automatically identify and convert to each other, but also support support mouse drag and so on, very good small tools ...

Go: How encoding is set in eclipse

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.