jQuery: The Write Less, Do More JavaScript Library

jQuery and charset encoding

View: New views
3 Messages — Rating Filter:   Alert me  

jQuery and charset encoding

by jpcaissy-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hey everyone!

I'm startint to work with jQuery and trying to learn from it but I am
stuck with a little problem.
I use jQuery's ajax to query a server which returns a page encoded in
iso-8859-1, but when I display those pages, of course all the special
caracters can't be displayed (french accents). From what I have read,
jQuery converts to UTF-8.
The problem here is that I cannot acces the server's page to change
the page to utf-8. Is there any ways for jQuery not to change the
encoding it received?

I did search abit around the group, jquery's forum and google but
could not find anything useful.

Thanks for the help!
JP

Re: jQuery and charset encoding

by Karl Rudd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


jQuery doesn't change anything, JavaScript's "internal" character set is UTF-8.

If you can't change what the server returns then you'll have to
convert from ISO-8859-1 to UTF-8. A quick Google search didn't turn up
any obvious JavaScript to do this but there are quite a few PHP and
Pearl based functions that you might be able to convert to do the job.

For instance:
    http://lachy.id.au/log/2005/11/handling-character-encodings
    http://algorytmy.pl/doc/php/function.iconv.php (see the comments)

Karl Rudd

On Thu, Jul 24, 2008 at 12:59 AM, jpcaissy <zedieu@...> wrote:

>
> Hey everyone!
>
> I'm startint to work with jQuery and trying to learn from it but I am
> stuck with a little problem.
> I use jQuery's ajax to query a server which returns a page encoded in
> iso-8859-1, but when I display those pages, of course all the special
> caracters can't be displayed (french accents). From what I have read,
> jQuery converts to UTF-8.
> The problem here is that I cannot acces the server's page to change
> the page to utf-8. Is there any ways for jQuery not to change the
> encoding it received?
>
> I did search abit around the group, jquery's forum and google but
> could not find anything useful.
>
> Thanks for the help!
> JP
>

Re: jQuery and charset encoding

by dave.methvin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


If there is nothing in the header saying otherwise, the default
encoding of any page returned to a browser with a MIME type of "text/
*" is assumed to be ISO-8859-1. What content type is being returned in
the AJAX request?

Perhaps you are running into this bug? Which browsers are you using
for testing?
http://swik.net/PHP/Planet+PHP/Encoding+issue+with+XMLHttpRequest+and+Firefox+3
LightInTheBox - Buy quality products at wholesale price