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):
And there you go! Now you can start coding in your favorite encoding scheme!