FAQ
We were having some problems with UTF-8 output via
Catalyst::Action::Serialize::JSONP which Catalyst::Controller::REST
uses for JSONP output. Basically, unicode data was not being read
correctly by browsers when read via JSONP, whereas it was fine as
JSON.

A solution that worked for us was to edit
Catalyst::Action::Serialize::JSONP and add "; charset=utf-8" to the
content type header:

$c->res->content_type('text/javascript; charset=utf-8');

My guess is that browsers treat text/javascript content differently
than application/json content and require the addition of the charset
to the content-type to read it correctly.

Does this seems like a reasonable solution to our problem? Is there a
better way?

Thanks!
Jim

Search Discussions

  • Tomas Doran at Mar 1, 2011 at 6:00 pm

    On 1 Mar 2011, at 16:55, James Spath wrote:
    Does this seems like a reasonable solution to our problem? Is there a
    better way?
    Were you using Plugin::Unicode::Encoding?

    It should do this for you I think...

    Cheers
    t0m
  • James Spath at Mar 1, 2011 at 8:35 pm

    On Tue, Mar 1, 2011 at 1:03 PM, Tomas Doran wrote:
    On 1 Mar 2011, at 16:55, James Spath wrote:

    Does this seems like a reasonable solution to our problem? ?Is there a
    better way?
    Were you using Plugin::Unicode::Encoding?

    It should do this for you I think...
    This plugin does add the necessary charset to the content type header,
    however, the output is still garbled for me.

    I will look into this further.
  • James Spath at Mar 1, 2011 at 8:38 pm

    On Tue, Mar 1, 2011 at 3:35 PM, James Spath wrote:
    On Tue, Mar 1, 2011 at 1:03 PM, Tomas Doran wrote:
    On 1 Mar 2011, at 16:55, James Spath wrote:

    Does this seems like a reasonable solution to our problem? ?Is there a
    better way?
    Were you using Plugin::Unicode::Encoding?

    It should do this for you I think...
    This plugin does add the necessary charset to the content type header,
    however, the output is still garbled for me.

    I will look into this further.
    Does Plugin::Unicode::Encoding cause problems if the $body is already
    properly encoded?

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedMar 1, '11 at 4:55p
activeMar 1, '11 at 8:38p
posts4
users2
websitecatalystframework.org
irc#catalyst

2 users in discussion

James Spath: 3 posts Tomas Doran: 1 post

People

Translate

site design / logo © 2022 Grokbase