views:

128

answers:

2

Hi,

We are implementing i18n using JSTL and encountered an issue that the resource texts defined in .properties file and having non ISO 8859 characters (e.g. inidic languages) can not be rendered by tag.

After diving through the code of tag and BundleHelper class ultimately we found that it internally uses ResourceBundle.getBundle method which in turn use PropertyResourceBundle to load the .properties file as resource bundle.

It internally relies on java.util.Properties#load(InputStream) method which does not support reading of non ISO 8859 characters and the only work around is to represent such characters in /u hex hex hex hex format, which is quite impractical in case if entire .properties file is for Hindi language !

Is there any work around for this. I tried using XML Format in .properties file but it was not recognized by PropertyResourceBundle !

Environment details are : Jdk 1.5, Weblogic 9.2

+1  A: 

Do you absolutely have to use JDK 1.5? If you could move up to 1.6, you could use the load(Reader) overload which would let you store the files in other encodings (e.g. UTF-8). I'm not sure how that would fit in with PropertyResourceBundle, admittedly.

Don't forget that even working with ISO-8859-1 files, you don't have to use that format to edit the file. You can use native2ascii to convert a file from a different encoding. Keep your "source" property files as UTF-8, then run native2ascii as part of your build. For example:

native2ascii -encoding UTF-8 Foo.properties.utf8 Foo.properties
Jon Skeet
A: 

Write your files in whatever encoding you like and run them through the native2ascii tool (which comes with the JDK for exactly this purpose) as part of the build or deployment process.

Michael Borgwardt