GWT: Character encoding umlauts

Patricia Odermatt picture Patricia Odermatt · Jan 2, 2012 · Viewed 11.2k times · Source

I want to set a text in a label:

labelDemnaechst.setText(" Demnächst fällig:");

On the output in the application the characters "ä" are displayed wrong.

How can I display them well?

Answer

Thomas Broyer picture Thomas Broyer · Jan 2, 2012

GWT assumes all source files are encoded in UTF-8 (and this is why you see löschen if you open them with an editor that interprets them as Windows-1252 or ISO-8859-1).

GWT also generates UTF-8-encoded files, so your web server should serve them as UTF-8 (or don't specify an encoding at all, to let browsers "sniff" it) and your HTML host page should be served in UTF-8 too (best is to put a <meta charset=utf-8> at the beginning of your <head>).

If a \u00E4 in Java is displayed correctly in the browser, then you're probably in the first case, where your source files are not encoded in UTF-8.

See http://code.google.com/webtoolkit/doc/latest/FAQ_Troubleshooting.html#International_characters_don't_display_correctly