Search code examples
javaspringjsppropertiesproperties-file

Special characters in properties file


In my Java/Spring web application i had problem printing special characters of italian language (ò,à,è etc.) that I retrieve from a properties file.

I found this article http://docs.oracle.com/cd/E26180_01/Platform.94/ATGProgGuide/html/s1816convertingpropertiesfilestoescap01.html.

But something is not clear: after I run the command written in the article, in my console (CMD console of windows) i can read my properties file "translated". After it, what should i do?

Should I copy the texts from the windows console and paste them into my properties file? It doens't seem a "professional" work!


Solution

  • There's no need in copying the output, you may just redirect it to the file:

    native2ascii notTranslated.properties > translated.properties
    

    Also, if you're building your project with Ant, you can use native2ascii ant task, for example:

    <native2ascii src="srcdir" dest="srcdir" includes="**/*._properties" ext=".properties"/>
    

    I assume here, that the initial non-ASCII properties files are named *._properties in your project.