While ago I found a problem which appears to be connected to application.properties in my java spring app. On local dev machines we use simple application.yml files which are compiled into app (I guess?), but when we deploy on production we use more secure properties. It seems that some of them are read wrong. So my question is what kind of characters are prohibited in application.properties file? How can I escape these characters?
Asked
Active
Viewed 1,040 times
-1
-
1If the problematic characters are accented vowels (áéíóú etc) then [this question](https://stackoverflow.com/questions/25969036/special-characters-in-properties-file) may be of relevance. – jsheeran Nov 23 '18 at 08:20
-
Sadly, that is not the case - I have few @!# characters but I was wondering what kind of characters except accented ones are not read correctly – mkubacki Nov 23 '18 at 08:47
1 Answers
3
The YAML format supports UTF-8 by default, whereas properties files must be encoded and are read in the ISO-8859-1 encoding by definition. So any non-ISO-8859-1 character is going to cause you issues unless you escape them in the .properties files.
You escape the Unicode characters in properties files by using their hex code prefixed with "\u". For example, "ä" would be encoded as \u00E4
, and the snowman, ☃, would be encoded as \u2603
. You can find the escape codes, for example, here.

ZeroOne
- 3,041
- 3
- 31
- 52