Reputation: 51
I get different results on two different systems and don't know why.
Properties prop = new Properties();
prop.load(new ByteArrayInputStream(input)); //input is byte[]
On both systems input contains "var=\\u00C4\\u00DC\\u00D6\\u00E4\\u00FC\\u00F6"
.
On my test system prop contains "var=ÄÜÖäüö"
. (This is what I want)
On another system prop contains "var=\xC4\xDC\xD6\xE4\xFC\xF6"
. This is input
in hex, but why does Properties
do this? I unfortunately know nothing about the other systems configuration.
Has someone an idea about the reason?
Upvotes: 4
Views: 7992
Reputation: 18304
Java .properties
files are encoded with ISO-8859-1
(Latin-1
), NOT UTF-8
. All non-Latin-1 characters must be entered by using Unicode escape characters, e.g. \uHHHH
.
An alternative is to use the XML
format for properties, which IS UTF-8
.
Upvotes: 8