[Catalyst] Re: ajax character encoding issue solved, but WHY?
Aristotle Pagaltzis
pagaltzis at gmx.de
Sat Jun 20 10:50:08 GMT 2009
* seasprocket at gmail.com <seasprocket at gmail.com> [2009-06-19 06:30]:
> The issue was that non-ascii chars were appearing as junk BUT
> only when retrieved via ajax calls. Otherwise, they displayed
> fine. The junk display was due to them being interpreted as
> ISO-8859-1, but I could not figure out why the browser was
> interpreting that way. All my data is handled as UTF-8.
>
> The problem was fixed by calling utf8::decode on the data prior
> to sending back via ajax. BUT WHY?
Looks like your code is broken and assumes bytes throughout; as
long as all your data is UTF-8 you won’t notice. Apparently the
JSON serialiser is trying to produce UTF-8 output correctly by
encoding the strings you pass it; since they’re already encoded,
you get double-encoding gremlins.
Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>
More information about the Catalyst
mailing list