UTF-8 in java applet in browser
I have a problem with encoding in java applet. Whe开发者_开发问答n I am running it in NetBeans, russian characters in applet are ok. No encoding problems. But, when I am running the same applet through browser, then my russian characters are shown as squares(encoding problem).
Where is the problem?
I have russian translations in .properties files, which has UTF-8 encoding. Also I tried to convert them to UTF-8 using
value = new String(bundle.getString(cLabel).getBytes("ISO-8859-1"), "UTF8");
Some ideas?
By default, .properties files are plain ISO8859-1, and any characters not represented there must be encoded via escape sequences, see the native2ascii program that comes with the JDK on how to convert them.
Pass this property to your applet:
java_arguments="-Dfile.encoding=utf-8"
(note that depending on the html code you use, the syntax might be different, but the attribute name is java_arguments
and the value is -Dfile.encoding=utf-8
)
精彩评论