utf-8 madness
As I wrote, I’m working on a stupid ajax (intranet) site but I’ve a lot of problem with charset encoding.
I’ve to publish, for legacy problem, all the intranet site using old ISO-8859-1 encoding BUT using the js XMLHttpRequest the data I receive is always UTF-8.
Unlucky I cannot use php to re-parse the data and to trasform to a latin encoding, anyone has a good idea to resolve this? Can I force another encoding on XMLHttpRequest?
Ok, I’m too tired to see the obvious… To resolve the problem I had simply forced the encoding via the php header function in the file I call remotely:
header(”Content-Type: application/x-javascript; charset=ISO-8859-1″);
echo $output;
now the browser show the right ÎÑTËRÑÅTÌÔñ�L strings
ciuaz
6 comments so far
Rispondi



php rulez :p
[...] Another brick to resolv the encoding issue with ajax is settled, last week I ranted about the problem on showing data from a remote script inside a page encoded with ISO-8859-1. [...]
You just saved my life… =)
I was having the exact same problem and there was no way in hell I could get it to work properly, until I found your post and saw the obviousness of the solution!
Thanks a lot!
cool!!!!
simple solution
Thanks man – it works! I needed iso-8859-2 ;D I spent 2 hours trying to solve the problem using iconv, then JavasScript escape + unescape, and urlencode + urldecode. Ufff… But tell me what is the ‘application/x-javascript’ mime – what does it mean? Thanks!
Nice. I was looking for this simple solution