views:

184

answers:

2

I am using the UIBinder in GWT but I have problems displaying letters with an accent.

My xml looks like this

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"&gt;    
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" 
xmlns:g="urn:import:com.google.gwt.user.client.ui">

...

<g:Label ui:field="lbl"></Label>

If I type my text directly in the xml <g:Label>éç</g:Label> the accents come out fine. But if I use the setText method in the associated class lbl.setText("éç") they are replaced by a diamond with a question mark in it.

Edit: If if type them in html it displays the ampersand and stuff

SOLUTION:

In fact when I tested the app after changing the file format to UTF-8 I hadn't went back through the code to retype all the accent which were broken during the change. So they still appeared the same in the browser.

+3  A: 

You need to set the response encoding and client encoding to UTF-8 as well.

Add this to top of your page to instruct the XML parser to use UTF-8:

<?xml version="1.0" encoding="UTF-8"?>

Add this to the HTML <head> to instruct the client to use UTF-8:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
BalusC
+1 .. and in addition, set the charset to UTF-8 in the Content-Type http response header. Don't know what takes precedence, but it doesn't harm to be consistent across the board.
sri
@sri: If the XML parser is smart, it should already have done it based on XML declaration :) I don't do GWT, but JSF+Facelets (which does similar job) does it. I'd expect GWT to do the same.
BalusC
A: 

After doing BalusC tasks check your File Save Option go to >> 'File\AdvancedSaveOptions...' and check if your page saved as Unicode (UTF-8 with signature) codepage 650001.

Your issue may be because of using Windows Codepage 1252

just note that you have to retype your Unicode String

Nasser Hadjloo