Changing the encoding in Eclipse to UTF-8 – howto

Eclipse on Windows chugs along fine with its default encoding of Cp1252 (Cp1252 is basically a superset of the ISO-8859-1 encoding scheme, read more here) till we reach the world of unicode. And then it crashes and burns – horribly. Arguably, the most popular and useful encoding in the programming world today is the UTF-8 encoding scheme well at least in the Web world. It is still baffling as to why Eclipse continues to have Cp1252 as its default encoding mechanism and make changing to UTF-8 such a pain! In fact there is even a bug with a very long interesting discussion on the same – Eclipse default encoding bug.

Even though the discussion in the bug history argues about ‘compatibility’ issues being the main concern dissuading the Eclipse team from shifting to UTF-8 as the default, most of us would still like to work in UTF-8. Changing to UTF-8 encoding is simple in Eclipse but is extremely buggy and the random unpredictable behavior can be really irksome. In most cases, one or more of the following changes should suffice. If you are still getting an error while changing the encoding scheme, the best bet would be to close the workspace and restart the IDE! Seriously, no kidding.

I am using Eclipse Galileo as the base IDE but these steps should work on most version of Eclipse with minor differences (by the way, I am using the JAVA EE version).

For all the various options mentioned below, the first step is to traverse to the settings page as

Windows -> Preferences

1. Changing the entire workspace’s encoding scheme:

2. Changing the Text Editor’s encoding scheme (also works for the Java editor):

3. Changing the CSS editor’s encoding scheme:

4. Changing the HTML editor’s encoding scheme:

5. Changing the JSP editor’s encoding scheme:

And there you go! Now you can start coding in your favorite encoding scheme!


5 thoughts on “Changing the encoding in Eclipse to UTF-8 – howto

    1. I just checked on my macOS box – the default encoding is now set to UTF-8 (Eclipse Neon), so it looks like they did fix it after all! 🙂 … (of course, I’m assuming the same holds true for the Windows version as well!)

      Liked by 1 person

  1. Thks for this IHM explication. Do you know if it’s possible to specify some file extension encoding with eclipse pref files ? such as org.eclipse.core.resources.prefs generate in .settings folder.
    I’d like to specify Cp1252 for all my js files but I had to do this manually in Window > Preferences > General > Content Types > Text > Javascript Source File. I’d like it to be automatic with maven or pref files. Thks


Speak your mind!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s