views:

36

answers:

1

I have a resource file with the following string in it, note the special characters:

Questa funzionalità non è sostenuta: {0} {1}

After Maven does its process-resources (which I need for something else) I get:

Questa funzionalit� non � sostenuta: {0} {1}

Please tell me there is an easy fix to this?

+3  A: 

The text files that held the strings were Java properties files. By default, most files in an Eclipse project inherit the default encoding scheme from the container (Eclipse) -- in my case that is UTF-8. If you just manually add a text file to the project it does not set it to UTF-8!!

So my properties files were actually encoded as ISO-8859-1. I changed the default encoding in Eclipse by clicking right on the file and selecting properties. I then was forced to re-enter ALL the special characters.

The other part of the fix was to tell the Maven process resource plug-in to use UTF-8 encoding while processing resources. Instructions for that are here:

http://maven.apache.org/plugins/maven-resources-plugin/examples/encoding.html

And of course I had to implement a UTF-8 ResourceBundle.Control because (for backwards compatibility) the detault ResourceBundle is still ISO-8859-1. Details on that class can be found here:

http://www.mail-archive.com/[email protected]/msg03972.html

Hope this helps somebody someday.

HDave