Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
utf8 bug
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
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:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
xolo  
View profile  
 More options May 10 2012, 3:14 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bvn13  
View profile   Translate to Translated (View Original)
 More options May 10 2012, 3:35 am
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 написал:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
xolo  
View profile  
 More options May 10 2012, 3:48 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sebastian Riedel  
View profile  
 More options May 10 2012, 4:30 am
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

> just Mojo::JSON seems to have a problem.

Not a bug, templates work with characters and encoded JSON is bytes.

--
Sebastian Riedel
http://twitter.com/kraih
http://mojolicio.us


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
xolo  
View profile  
 More options May 10 2012, 4:45 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sri  
View profile  
 More options May 10 2012, 6:36 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
xolo  
View profile  
 More options May 10 2012, 7:23 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sri  
View profile  
 More options May 10 2012, 7:33 am
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

> ???, i think i'll continue to use JSON::XS. this works fine for me.

Perhaps you should take a look at http://perldoc.perl.org/perlunicode.html
and http://www.slideshare.net/Penfold/perl-and-unicode.

--
sebastian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
xolo  
View profile  
 More options May 10 2012, 8:48 am
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
sri  
View profile  
 More options May 10 2012, 12:42 pm
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.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »