How to use UTF-8 in resource properties with ResourceBundle

后端 未结 16 2384
难免孤独
难免孤独 2020-11-22 03:28

I need to use UTF-8 in my resource properties using Java\'s ResourceBundle. When I enter the text directly into the properties file, it displays as mojibake.

16条回答
  •  时光取名叫无心
    2020-11-22 03:40

    ResourceBundle.Control with UTF-8 and new String methods don't work, if the properties file uses cp1251 charset, for example.

    So I recomended using a common method: write in unicode symbols. For this:

    IDEA -- has a special "Transparent native-to-ASCII conversion" option (Settings > File Encoding).

    Eclipse -- has a plugin "Properties Editor". It can work as separate application.

提交回复
热议问题