简体   繁体   中英

ResourceBundle (Java)

I need the character like 'шел' in my .properties file.

It seems like ISO 8859-1 (Which seems to be the default .properties encoding) doesnt like these, and displays them as ?.

I want to support this characters, what to do?

EDIT: I made it work now, but everytime I use this it converts my file from UTF-8 to ANSI (So the file gets replaced with the same file but then in ANSI), really weird. Code: http://pastebin.com/r0h3CKXF

Any idea why this happens??

Unicode可以在属性文件中用\\uxxxx编码。

The Oracle JDK contains a tool named native2ascii that converts property files to Latin-1. Write your .property file in UTF-8, and then call

/path/to/jdk/bin/native2ascii -encoding utf8 input.properties output.properties

You can also read UTF-8 encoded .property files. See How to use UTF-8 in resource properties with ResourceBundle for a detailed description.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM