The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
xolo <xolomo... @googlemail.com>
Date: Thu, 10 May 2012 00:14:37 -0700 (PDT)
Local: Thurs, May 10 2012 3:14 am
Subject: utf8 bug
hi,
i encountered a problem when serializing utf8 data with Mojo::JSON.
when using JSON::XS everything works fine.
example: <http://pastebin.com/UXQBpUb8 >
xolo
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
bvn13 <mail4... @gmail.com>
Date: Thu, 10 May 2012 00:35:42 -0700 (PDT)
Local: Thurs, May 10 2012 3:35 am
Subject: Re: utf8 bug
I solve this problem with Mojo::HTML with using:
use encoding 'utf8';
in the header of utf8-encoded source.
Try it.
четверг, 10 мая 2012 г., 11:14:37 UTC+4 пользователь xolo написал:
> hi,
> i encountered a problem when serializing utf8 data with Mojo::JSON. > when using JSON::XS everything works fine.
> example: <http://pastebin.com/UXQBpUb8 >
> xolo
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
xolo <xolomo... @googlemail.com>
Date: Thu, 10 May 2012 00:48:03 -0700 (PDT)
Local: Thurs, May 10 2012 3:48 am
Subject: Re: utf8 bug
> use encoding 'utf8';
> in the header of utf8-encoded source.
> Try it.
sorry... but this does not work. as far is i understand "use utf8;" does
the same.
$self->app->log->info($test1->[0]);
shows the correct output... so it seems to be ok. just Mojo::JSON seems to have a problem.
thanks, anyway!
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Sebastian Riedel <kra... @googlemail.com>
Date: Thu, 10 May 2012 10:30:10 +0200
Local: Thurs, May 10 2012 4:30 am
Subject: Re: [Mojolicious] Re: utf8 bug
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
xolo <xolomo... @googlemail.com>
Date: Thu, 10 May 2012 01:45:57 -0700 (PDT)
Local: Thurs, May 10 2012 4:45 am
Subject: Re: [Mojolicious] Re: utf8 bug
On Thursday, May 10, 2012 10:30:10 AM UTC+2, sri wrote:
> > just Mojo::JSON seems to have a problem.
> Not a bug, templates work with characters and encoded JSON is bytes.
ok, but what do i have to write when i want to embed an utf8 containing
json-string in an html template?
changing my example to...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ use Mojo::ByteStream qw(b); ... $self->stash( test => b(Mojo::JSON->new->encode($test))); ... __DATA__
@@test.html.ep <%= $test %> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
does not work neither
xolo :-(
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
sri <kra... @googlemail.com>
Date: Thu, 10 May 2012 03:36:35 -0700 (PDT)
Local: Thurs, May 10 2012 6:36 am
Subject: Re: [Mojolicious] Re: utf8 bug
> ok, but what do i have to write when i want to embed an utf8 containing > json-string in an html template?
Just turn the bytes back into characters.
-- sebastian
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
xolo <xolomo... @googlemail.com>
Date: Thu, 10 May 2012 04:23:27 -0700 (PDT)
Local: Thurs, May 10 2012 7:23 am
Subject: Re: [Mojolicious] Re: utf8 bug
> Just turn the bytes back into characters.
???, i think i'll continue to use JSON::XS. this works fine for me.
thanks anyway...
xolo
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
sri <kra... @googlemail.com>
Date: Thu, 10 May 2012 04:33:12 -0700 (PDT)
Local: Thurs, May 10 2012 7:33 am
Subject: Re: [Mojolicious] Re: utf8 bug
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
xolo <xolomo... @googlemail.com>
Date: Thu, 10 May 2012 05:48:08 -0700 (PDT)
Local: Thurs, May 10 2012 8:48 am
Subject: Re: [Mojolicious] Re: utf8 bug
On Thursday, May 10, 2012 10:30:10 AM UTC+2, sri wrote:
> > just Mojo::JSON seems to have a problem.
> Not a bug, templates work with characters and encoded JSON is bytes.
rfc4627 says "3. Encoding: JSON text SHALL be encoded in Unicode. The
default encoding is UTF-8"
so the root of my problem seems to be an implementation detail... JSON::XS uses UTF-8 as default encoding while Mojo::JSON delivers bytes.
xolo
ps: so i could write "decode_utf8(Mojo::JSON->new->encode($test))" or just use JSON::XS which default encoding makes my code shorter (and faster?!). ;-)
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
sri <kra... @googlemail.com>
Date: Thu, 10 May 2012 09:42:15 -0700 (PDT)
Local: Thurs, May 10 2012 12:42 pm
Subject: Re: [Mojolicious] Re: utf8 bug
> so the root of my problem seems to be an implementation detail... JSON::XS > uses UTF-8 as default encoding while Mojo::JSON delivers bytes.
JSON::XS obviously does not generate UTF-8 but Perl characters, something
can't be UTF-8 if it isn't bytes.
-- sebastian
You must
Sign in before you can post messages.
You do not have the permission required to post.