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?
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.
Source: Javadoc
Also see this SO question
And this one
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With