PDA

View Full Version : Welsh Character



ginzsa
30 Jun 2010, 3:16 AM
Hi, I am trying to display welsh ( ) characters in the tree node text.
I am using the tree loader that includes the dataUrl

Instead, I am getting this character (firefox) ?

The server is set to URIEncoding="UTF-8", also the jsp page encode=utf-8 and set the browser to utf-8
without any positive result.

I also added the basePrams: { 'charset' :'UTF-8' } without luck

Every time I set the response.setEncoding to UTF-8 or replace the character with the encoding
Î or \u00CE the node does not render.

I hope is clear.
Does any one had that problem before?

thanks in advance
S.

Animal
30 Jun 2010, 3:20 AM
If you use a good JSON library to generate the JSON response this will all just work.

Because it will encode that as "\u00CE" which will work. If the browser has a glyph for that Unicode codepoint in that font.

ginzsa
30 Jun 2010, 8:03 AM
thanks Animal, I checked with firebug (net) the http response from server and I can see the welsh character ( ) in the JSON Array within the tree node text property. but extjs is still rendering ? .

Animal
30 Jun 2010, 11:12 AM
So you are not using a JSON library to create the JSON then.

A JSON library would send the String quoted eg



{
"theCharacter": "\u00Ce"
}

ginzsa
1 Jul 2010, 1:50 AM
true, Im using the source from www.json.org/java/ do you know a better one?

Animal
1 Jul 2010, 2:20 AM
That's a good one. It's what we use.

I just tested and see that it does not quote non ISO-8859 characters.

So you must make sure that your response is encoded using an encoding which is able to send those characters.



myHttpServletResponse.setCharacterEncoding("UTF-8");

ginzsa
1 Jul 2010, 3:40 AM
Yea.. Thanks, it is working now,

I did have the myHttpResponse.setCharacterEncoding("UTF-8");

but

I was using the myHttpResponse.getWriter().write(myjson.toString());

instead of

myjson.write(myHttpResponse.getWriter());

thanks a lot S.

lamerexter
1 Jul 2010, 3:57 AM
Nice one. I'd have been surprised if JSON-lib did much at all. In actual fact, because
you set the proper encoding of the stream to UTF-8 then JSON-LIB isn't doing anything for you: it just works
fine now that the encoding is correct.

i.e. Java in-memory String (UTF-16) ---> UTF-8 Stream IS FINE, but
Java in-memory String (UTF-16) ---> ISO_8859-1 Stream IS NOT FINE and are not totally compatible!

Cheers,

Gary

Animal
1 Jul 2010, 4:05 AM
Yes, the

myjson.write(myHttpResponse.getWriter());

is just more efficient I would think.

They key is how the Unicode characters get encoded into a stream of 8 bit bytes.