Character set that understands property files
If you are a Java developer in a non-ISO8859-1 environment, you will have encountered the character set problem when editing property files. The spec says that they are in ISO8859-1, with Unicode escape sequences for characters outside that set. While one can set up automatic translation, it is intrusive and not suited to all cases. Being fed up with the problem and the inelegance of all the available solutions, I wrote a custom character set provider which handles the property file encoding as a multi-byte character set.
The source is here, and the prebuilt JAR is here. To use the property character set, drop the JAR file in the extension folder of your JRE, usually $JAVA_HOME/lib/ext and restart (or start) your application. Property files should be assigned the "X-PROP" character set, and all should be ready.
If you are using Eclipse 3.1 or later, simply go to Window → Preferences →
General → Content Types → Text → Java Properties files, set the default
encoding to X-PROP and select
Update to apply the setting.
The code is in the public domain, and I'm not responsible if it munges your files, destroys your computer or causes the next ice age, etc...



Comments