Question

In struts application.properties we have key and value pairs. We use this file to display static text on html/jsp pages in browser.

But when I entered German characters from : http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_script_charset

entered this text : αβγδεζηθ (Greek Symbols)

at some button in html page, it shows some different characters:

enter image description here

Note : i have used file encoding as UTF-8 in this case, and then compile the code.

What should i do to support these characters also. Please give some links so that it would be helpful.

Thanks....

Était-ce utile?

La solution

Some characters cannot be stored AS IS on the properties file, it will have to entered using Unicode escape characters:

The default encoding for property files is ISO-8859-1 also known as Latin-1 characters. All non-Latin-1 characters must then be entered using Unicode escape characters.

Example, consider the following example using a french sentence:

#property file example:
sentence.french=Son père est allé à l'hôtel.

There are certain accents that are not part of the Latin-1 character set. Therefore, escaping it to its Unicode escape characters, we get:

#property file example:
sentence.french=Son p\u00e8re est all\u00e9 \u00e0 h\u00f4tel.

I hope this helps.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top