Setting Unicode text in Text Box and Text Area

2,650 views
Skip to first unread message

Anurag Setia

unread,
Nov 4, 2009, 4:34:48 AM11/4/09
to Google Web Toolkit
I am trying to set some unicode text to display some unicode supported
language text in a textbox and a textarea. I am using the decimal
representations used by HTML for the same purpose in the format
ї

The same gets display if I use this data in a JSP and shows up in the
text box, however, when I am setting it through GWT i.e. setText or
setValue, i see the decimal representation in the page.

Any clue...

PS - content type of the page is set to UTF-8

Thomas Broyer

unread,
Nov 4, 2009, 6:01:28 AM11/4/09
to Google Web Toolkit
setText and setValue takes text, not HTML. The fact that it works in
your JSP is because you're putting the value within the HTML that'll
be parsed by the browser when loading the page; it's not using
JavaScript.

Just use \u1111 or the actual character you want to display (you're
using UTF-8, which is able to encode any Unicode code-point, so it
shouldn't be a problem).

Anurag Setia

unread,
Nov 4, 2009, 11:18:17 AM11/4/09
to Google Web Toolkit
On Nov 4, 4:01 pm, Thomas Broyer <t.bro...@gmail.com> wrote:
>
> setText and setValue takes text, not HTML. The fact that it works in
> your JSP is because you're putting the value within the HTML that'll
> be parsed by the browser when loading the page; it's not using
> JavaScript.
>
> Just use \u1111 or the actual character you want to display (you're
> using UTF-8, which is able to encode any Unicode code-point, so it
> shouldn't be a problem).

This doesnt work either.. tried with hexa as well as decimal code
points.

I thought of adding a new text box with the content as well.. didnt
work either.

Anurag Setia

unread,
Nov 5, 2009, 5:51:11 AM11/5/09
to Google Web Toolkit
Guys,

Just an update for anyone interested.

After a bit of fiddling... the setInnerHTML works with a TextArea.

It wouldnt work for TextBox for it being an atomic tag.
Element.setAttribute("value",..) does set the value but doesnt seem to
handle Unicode.

So atleast part of my problem is resolved.

Thomas Broyer

unread,
Nov 5, 2009, 9:03:13 AM11/5/09
to Google Web Toolkit


On 5 nov, 11:51, Anurag Setia <anurag.se...@gmail.com> wrote:
> Guys,
>
> Just an update for anyone interested.
>
> After a bit of fiddling... the setInnerHTML works with a TextArea.
>
> It wouldnt work for TextBox for it being an atomic tag.
> Element.setAttribute("value",..) does set the value but doesnt seem to
> handle Unicode.

It *does* handle Unicode, just not when using HTML's character
references (because it's not parsing HTML):

textBox.setValue("résum\u00E9");
or
textBox.setValue("raw ї and using Java escape \u0457");

Your issue might be related to how and where you get that value from.
Reply all
Reply to author
Forward
0 new messages