views:

337

answers:

1

Hi,

I work on a website which is all done in iso-8859-1 encoding using old ASP 3.0. I use Yahoo YQL to request data (XML) from external websites but which I request to be returned as JSON-P (JSON with a callback function so I can retrieve the data).

The problem I am facing is that YQL seems to always return data encoded in utf-8, which is bad for me when I try to display any textual data retrieved from that query. Characters like é, à, ô, get gibberished in IE6 & IE7 since the encoding does not match.

Anyone knows how to convert utf-8 data retrieved via JSON-P with YQL to iso-8859-1 and be displayed correctly ?

I already tried that solution, but it does not work. Server side functions are not an option too, ASP 3.0 does not include function such as utf8_decode.

Thank you

+2  A: 

I have no idea whether this will work, but here's something you can try if you want.

A <script> tag can have a charset attribute specified when referencing a remote JS file. See the theory here. This definitely works for content that is stored inside the JavaScript file and e.g. output using document.write.

Whether the implicit conversion works for data fetched by a routine defined in that file through JSONP? I have no idea. My guess is, probably not. I can't test it right now but if you do, I'd be very interested in the outcome.

Pekka
Wouldn't this be more to do with the actual page's encoding? Even with the script set to the correct charset, any output to the document would reset it back to the document's charset, wouldn't it?
Andy E
As I said, it works when doing `document.write`s within the script: The data is converted correctly from the script's into the document's encoding (which is what the OP is looking for). Whether it works for data that the script fetched from somewhere, I don't know.
Pekka
I'll try it on at work tomorrow morning and keep you informed
MaxiWheat
No luck, it does not work :-(
MaxiWheat