PDA

View Full Version : [Resolved] Unicode Chracters in Grid are not rendered correctly



polydyne
4 May 2010, 12:33 PM
Hi,
I have a grid which can have international characters. For some reason unicode chracters are displayed as '?'. I do have utf-8 in database, browser and jsp. The "project name" is displaying fine in Chinese chrs on jsp page itself but the same thing is displayed as question marks on grid. I have tried looking for solns but cant seem to find one. Please help.

Here is the json-


"[{"rowIdx":0,"namespaceId":2961,"locked":false,"project":"\u641c\u5c0b","description":"","checklist":"gray","value":"","value2":"","currency":"USD","division":"2.1 TESTING","projectowner":..

wm003
4 May 2010, 9:16 PM
Is the jsp-file itself saved in UTF-8 on the server? (The file that serves the JSON to the Grid-Store)
Have you used a meta-tag for Charsetset UTF8 in the output HTML? (guess so..)
Do you send HTTP Headers with charset UTF-8 before any JSP Output? (guess so..)

Animal
4 May 2010, 9:21 PM
It's nothing to do with the encoding. The characters are encoded in Javascript.

I suspect the font the OP is using does not contain glyphs for those codepoints.

polydyne
5 May 2010, 6:53 AM
Is the jsp-file itself saved in UTF-8 on the server? (The file that serves the JSON to the Grid-Store)
Have you used a meta-tag for Charsetset UTF8 in the output HTML? (guess so..)
Do you send HTTP Headers with charset UTF-8 before any JSP Output? (guess so..)

Hi,
Thanks for the reply.

1) The Json is coming from a java class. I am using Json-lib's JsonObject to convert to json string
2) I have tried using the meta-tag in the file but the same issue
3) Yes

I am sure there is some thing to do with Json object, I tried hard coding the unicode chars in header of one of the columns in ColumnModel and it displays fine but same thing in grid cell is displayed as ?

Thanks,
-Polydyne

polydyne
5 May 2010, 6:55 AM
Hi Animal.
Pl. take a look at my other reply. I am not sure what is OP. Thanks.

Animal
5 May 2010, 7:08 AM
If the JSON is encoded using "\uxxxx" then that is the Unicode codepoint at that character position in the string.

The browser just can't display it.

Just type



Ext.Msg.alert("\u641c\u5c0b")


into your command line to test this.

FF and Chrome display some chinese characters.

polydyne
5 May 2010, 7:10 AM
I did that and it is displaying chinese chars..

polydyne
5 May 2010, 7:41 AM
Guys,
I think I found the bottleneck.

As I said, I am using java servlet to create json string. I am using rsp.getWriter().write(jsonResult); to give back the json result. So I assumed that rsp.getWriter is in UTF-8 format, but it was not. I had to use rsp.setCharacterEncoding("UTF-8"); and its spitting the correct chars.