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=\\\Ä\\\Ü\\\Ö\\\ä\\\ü\\\ö"
.
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, eg \\uHHHH
.
An alternative is to use the XML
format for properties, which IS UTF-8
.
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.