Using Eclipse With Chinese (Or Other Foreign) Characters

We were developing a Chinese language localization for an application at work. And I here’s a few things that might help if you’re doing something similar.

Step 1. Download a Unicode Font

First, you need to a Unicode-capable font. Normally you would have Arial Unicode MS.

Step 2. Displaying Unicode Characters In Eclipse

Next, you need to configure Eclipse to use your Unicode font: Windows->Preferences->General->Appearance->Colors and Fonts. Edit the configurations to use your font.

Step 3. Saving Files With Unicode Characters

So you’ve typed out (or copy-and-pasted) your code into Eclipse and you try to save the file. Then you get this error:

Save Could Not Be Completed

Reason:

Some characters cannot be mapped using “ISO-8859-1” character encoding.
Either change the encoding or remove the characters which are not
supported by the “ISO-8859-1” character encoding.

The solution: You need to use UTF-8 encoding for your files.

  1. For Entire Eclipse Workspace: Go to Preferences>General>Workspace->Text File Encoding  as UTF-8
  2. For Entire Project: Go to Project->Properties->Text File Encoding and set to  UTF-8
  3. For Specific File: Right click the specific file and set Properties->Resource->Text File Encoding and set to  UTF-8

Step 4. Debugging

Finally, to show Unicode characters while debugging your code, you need to do the following:

  1. Go to Run-> Run/Debug Configurations->Common->Console Encoding and set to UTF-8
  2. Window->Preferences->Java->Installed JREs. Select the JRE you are using, click Edit,  and add -Dfile.encoding=UTF-8 in Default VM Arguments.

Your Eclipse should now be multi-lingual! :D

One Reply to “Using Eclipse With Chinese (Or Other Foreign) Characters”

  1. Thanks a lot,The above steps solved my issue in saving the property files…

Comments are closed.