Special characters in properties file

In my Java / Spring web application, I am having a problem printing the Italian special characters (ò, à, è, etc.) that I extract from the 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 running the command written in the article, in my console (CMD console for windows) I can read the properties file "translated". After that, what should I do?

Should I copy the texts from the Windows console and paste them into my properties file? It doesn't seem like a "professional" job!

+3


source to share


2 answers


There is no need to copy the output, you can just redirect it to a file:

native2ascii notTranslated.properties > translated.properties

      

Also, if you are building your project with Ant, you can use the native2ascii

ant task , for example:



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

      

I am assuming the source files for non-ASCII properties are named *._properties

in your project.

+4


source


The key contains all characters in the string, starting with the first non-white space, and up to, but not including, the first non-"=", ":" or "space" character other than the line terminator. All of these termination keywords can be included in a key by escaping them with the previous backslash character; eg,

\:\=

      



will be a two-character key ": =". Linear delimiters can be included using the \ r and \ n escape sequences. Any space after pressing a key; if the first non-white space character after the key is '=' or ':' then it is ignored and any spaces after it are also skipped. All other characters in the string become part of the associated element string; if there are no remaining characters, the item is the empty string "". Once the original character sequences constituting the key and element are identified, the escape processing is performed as described above.

See this link to avoid special char and see this link for reading in different UTFs.

0


source







All Articles