PDA

View Full Version : Why does Ext convert characters in my dataset?



Greffin
1 Oct 2009, 6:11 AM
Hi.

In my app I have a combobox which receives the following data:


{"DataItem":[
{"NAME":"AAM (Årdal)","ID":51},
{"NAME":"ASU (Sunndal)","ID":55},
{"NAME":"HAK (Karmøy)","ID":60},
{"NAME":"LUC (Lucè)","ID":66},
... and more
]}
.. but when the data is displayed in my app, it looks like this:


AAM (?rdal)
ASU (Sunndal)
HAK (Karm?y)
LUC (Luc?)
It would seem like Ext is converting the characters into a different character encoding. How can I make Ext NOT convert the characters? I like what I get from my DB. ;)

Animal
1 Oct 2009, 6:19 AM
Ext does not do anything.

This is a matter between your server and your browser.

Greffin
1 Oct 2009, 12:48 PM
This is a matter between your server and your browser.
If this was the case, I would expect Firebug to report the same text as ExtJS displays in it's console. The JSON I provide in the topmost code box, is fetched from Firebugs console after a GET operation, and the bottom code box is fetched by copy & paste from firebugs HTML element inspector at display time.

The data was one thing one the server, remained the same when the browser received it, but somehow changed when ExtJS had processed it in Store and displayed it.

I've seen this before when I try to convert none UTF-8 data to UTF-8. Could this be the case here?

Animal
1 Oct 2009, 1:38 PM
You must ensure that your server encodes the Unicode correctly, and sets the character encoding header to reflect that.

Greffin
2 Oct 2009, 4:35 AM
My index html includes the following:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">My java servlet throws out the following:

httpServletResponse.setCharacterEncoding("iso-8859-1");and this is the response header (fetched from firebug):

Response Headers
Date Fri, 02 Oct 2009 12:27:32 GMT
Content-Length 7730
Content-Type text/plain
X-Powered-By Servlet/2.5 JSP/2.1


How can I communicate to Ext that I do not display unicode?

Greffin
2 Oct 2009, 4:44 AM
Hmm... Got it:
httpServletResponse.setContentType("text/plain; charset=iso-8859-1");