SPUG: ajax character encoding issue solved, but WHY?
phil.mitchell at pobox.com
Tue Jun 16 20:47:04 PDT 2009
On Tue, Jun 16, 2009 at 9:55 AM, Johnston, Mark <mark.johnston at pnl.gov>wrote:
> This is a shot in the dark, but is the encoding on the page that
> interacts with the web service via AJAX by chance ISO-8859-1 (either set
> explicitly or by default on the server)?
No, all my html is served with charset=UTF-8
> You didn't mention whether "utf8" or "UTF-8" is the character encoding you
> are now specifying when calling Encode::decode on the JSON text stream, so
> I'm not sure how that might have affected the resulting text stream as it
> enters the wire between the two processes.
It doesn't seem to matter, both work. In fact, I ended up using
utf8::decode, thinking perhaps it is the most efficient.
I remain puzzled, but thanks for thinking about it!
> *From:* spug-list-bounces+mark.johnston=pnl.gov at pm.org [mailto:
> spug-list-bounces+mark.johnston <spug-list-bounces%2Bmark.johnston>=
> pnl.gov at pm.org] *On Behalf Of *Phil Mitchell
> *Sent:* Wednesday, June 10, 2009 12:41 PM
> *To:* spug-list at mail.pm.org
> *Subject:* SPUG: ajax character encoding issue solved, but WHY?
> I solved the character encoding issue that I wrote about earlier, but I
> don't understand why the fix works. I'm hoping someone can explain this to
> 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 Encode::decode on the data prior to
> sending back via ajax. BUT WHY?
> I am using the JSON view to render ajax responses, and it sets the charset
> header correctly to UTF-8. Of course, even when you decode, perl still
> represents as "internal" utf8. But why should this be necessary?
> 2People citizen's network for climate action: http://www.2people.org
> Greater Seattle Climate Dialogues: http://www.climatedialogues.org
> Seattle Perl Users Group Mailing List
> POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
> MEETINGS: 3rd Tuesdays
> WEB PAGE: http://seattleperl.org/
2People citizen's network for climate action: http://www.2people.org
Greater Seattle Climate Dialogues: http://www.climatedialogues.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the spug-list