Why not convert all .properties files to UTF-8?

爷,独闯天下 提交于 2020-01-02 23:15:12

问题


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:


  1. If you are using ResourceBundle, switching to ListResourceBundle might be feasible: that is pure java (arrays).
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!