问题
I use GWT i18n Messages to translate messages:
@DefaultLocale("en")
public interface Messages extends com.google.gwt.i18n.client.Messages {
@DefaultMessage("Size")
String size();
}
For German I have the Messages_de.properties
file.
size=Größe äüö ÄÖÜ
In one of my UIBinder templates I use
<ui:text with="{messages.size}"/>
When the user's browser is de
I get Grösse ÄÖÜ ÄÖÜ
instead of Größe äüö ÄÖÜ
being displayed.
My workspace as well as my .properties file is set to UTF8.
How can I get the special character ß
in German being displayed correctly or is there a way to include ASCII code?
Solution: When you set CSS text-transform: uppercase;
then ß
is transformed to SS
.
回答1:
This is a problem with the way Eclipse handles properties
files. You can set the whole workspace to UTF-8, it will still treat properties
files as ISO 8859-1
- because that's the default/expected encoding. However, GWT uses an enhanced properties file format that uses UTF-8 directly (without the need for escaping the characters).
You have to override this setting separately:

You can change the default encoding for all *.properties
files to UTF-8
there (don't forget to hit the Update
button).
But please note that this will mean treating all properties
files as UTF-8. So unless you are sure this will not break anything, I'd narrow down the file association for example to *Messages.properties
files (if all your translation files have the Messages
suffix). Or just use a different editor for editing the properties files.
回答2:
GWT is always UTF8. So the easiest way to solve your problem is, to set the encoding of your workspace to utf-8.
Or select your Messages_de.properties, right mouse button and select properties. Use Resources to set the encoding of your property file to utf-8.

来源:https://stackoverflow.com/questions/28505518/gwt-i18n-message-properties-does-not-display-special-character-like-%c3%9f