简体   繁体   中英

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!

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.

The key contains all of the characters in the line starting with the first non-white space character and up to, but not including, the first unescaped '=', ':', or white space character other than a line terminator. All of these key termination characters may be included in the key by escaping them with a preceding backslash character; for example,

\:\=

would be the two-character key ":=". Line terminator characters can be included using \\r and \\n escape sequences. Any white space after the key is skipped; if the first non-white space character after the key is '=' or ':', then it is ignored and any white space characters after it are also skipped. All remaining characters on the line become part of the associated element string; if there are no remaining characters, the element is the empty string "". Once the raw character sequences constituting the key and element are identified, escape processing is performed as described above.

See this link to escape special char and see this link to read by different UTF.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM