问题
I work on a java project where labels are externalized and translated into .properties
files.
Resources in java are read using ISO-8859-1 encoding and thus the .properties
files are also stored in ISO-8859-1 encoding.
The current files are messed up, sometimes using escapes \u00E4
and sometimes using the actual letter öäü
.
Also I have russian translations which look like this:
code.adr=\u0430\u0434\u0440\u0435\u0441
This could be stored in clear text using UTF-8.
Now the question is, why not use UTF-8?
Why does Java use ISO-8859-1 instead of UTF-8 per default, backwards compability?
Are there any known downsides, converting all .properties
files to UTF-8?
回答1:
- If you are using ResourceBundle, switching to ListResourceBundle might be feasible: that is pure java (arrays).
- Alternatively you might want to generate the *.properties from say an XML translation memory xliff or whatever. That has the advantage of being able to add comments; create a glossary and such.
来源:https://stackoverflow.com/questions/36769205/why-not-convert-all-properties-files-to-utf-8