How to use UTF-8 in resource properties with ResourceBundle

后端 未结 16 2464
难免孤独
难免孤独 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:57

    Attention: java property files should be encoded in ISO 8859-1!

    ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode escapes ; only a single 'u' character is allowed in an escape sequence.

    @see Properties Java Doc

    If you still really want to do this: have a look at: Java properties UTF-8 encoding in Eclipse -- there are some code samples

提交回复
热议问题