fredag, oktober 13, 2006

ResourceBundle pain.

I just found out something very disturbing and annoying. Java Property-files (and ResourceBundles in extension) will only load files in ISO-8859-1 format. Of course, you can use Unicode escape codes in the files, but that is not very convenient. Java is, over all, really good at internationalization, but this is one sore spot. And it doesn't seem to go away in Java 6 either. Isn't it highly ironic that ResourceBundles can't use regular UTF-8-files?

4 kommentarer:

Rog sa...

I think that you can use the "native2ascii" program that comes with the sdk to convert your property files after you are done editing them. It's a little less annoying than trying to edit the files in \uxxxx format. Or, if you use Vim, try my unicodeswitch.vim plugin to view in utf-8 and write in the \uxxxx format: http://www.vim.org/scripts/script.php?script_id=909

Roger

Unknown sa...

I hear you Ola. I went through the same realization a few months ago. Roger: I didn't know about native2ascii and I ended up essentially writting my own version of it. Documentation was weak overall, I had to go through a lot of digging.

Anonym sa...

There are two flavours of properties files - the name=value we all know well, and XML properties files.

The later has full support for encodings beyond ISO-8859-1 but writing them has a serious impact on one's will to live.

I'm not sure if ResourceBundles can be written in property file XML.

Anonym sa...

Mmm.. Don't know if I quiote agree with you.. But I don't have a good argument against you yet :)

DJ Perth Drop by and visit us some time..