469,338 Members | 8,155 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,338 developers. It's quick & easy.

Latin encoding in ajax

Hi, i am trying to fill a dropdown menu with ajax, but the table
contains latin characters. In mozilla i get a weird black character
instead, and in internet explorer the whole code breaks because if a
word ends in a latin character then it ignores the <bri put on the
end, therefore affecting my data logic.

I am using results = http.responseText.split("<br>"); as a delimiter.

Is there a way to fix this without resorting to using xml encoding?

Aug 1 '06 #1
2 2097


Seguros Catatumbo wrote:
Hi, i am trying to fill a dropdown menu with ajax, but the table
contains latin characters. In mozilla i get a weird black character
instead, and in internet explorer the whole code breaks because if a
word ends in a latin character then it ignores the <bri put on the
end, therefore affecting my data logic.

I am using results = http.responseText.split("<br>"); as a delimiter.
Mozilla (and Opera) should do if you tell them the encoding with a HTTP
response header e.g.
Content-Type: text/html; charset=WINDOW-1252
or
Content-Type: text/html; charset=ISO-8859-1

But with IE which uses MSXML if you use responseText I can only suggest
to make sure your response sent to the browser is UTF-8 encoded. MSXML
assumes that when decoding the response body.
Or use JSON which sends strings as ASCII with other characters in
JavaScript being encoded by JavaScript means (e.g. \uhhhh or \xhh).

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 1 '06 #2
Seguros Catatumbo wrote:
Hi, i am trying to fill a dropdown menu with ajax, but the table
contains latin characters. In mozilla i get a weird black character
instead, and in internet explorer the whole code breaks because if a
word ends in a latin character then it ignores the <bri put on the
end, therefore affecting my data logic.

I am using results = http.responseText.split("<br>"); as a delimiter.

Is there a way to fix this without resorting to using xml encoding?
I think you can diagnose your problem by finding out what is the hex
code that causes the trouble:

var str = 'Xéл€';
for (i=0;i<str.length;i++)
alert('hex code at pos '+i+' is '+str.charCodeAt(i).toString(16));

Then you could replace the hex value of the wrong character by another
character. Say you find out the Euro-sign would be your problem (hex
20AC), and you want to replace it by capital 'E', then you could do
something like:

str = '€';
uhex = '\\' + 'u' + str.charCodeAt(0).toString(16);
str = str.replace(new RegExp(uhex,'g'),'E')
alert(str)

Hope this helps,

--
Bart

Aug 2 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by francescomoi | last post: by
17 posts views Thread by thinkfirst | last post: by
10 posts views Thread by Arne | last post: by
2 posts views Thread by Riku Kangas | last post: by
9 posts views Thread by Andy | last post: by
1 post views Thread by Chris Curvey | last post: by
23 posts views Thread by Allan Ebdrup | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.