« I just ditched Mail.app for Postbox | Main | Thoughts about the Personally Encrypted IMAP Storage proposal »
mars 10, 2010
UTF8 with Perl CGI.pm and Ajax
It took me about three hours to figure out something this simple, so I'm posting this here!
If you're doing ajax stuff with CGI.pm in perl, you'll want to exchange your data in UTF8, to do so you need only one special line of code*:
my $json = decode utf8=>$q->param('json');
This will make perl work natively in UTF8 with $json.
If you want to put this (or part of it) in a database, you don't need to do anything special because the DBD driver will convert your string from UTF8 to the database encoding (UCS-2 in my case).
*Of course, you'll also need to use Encode;.
Posted by gfk at mars 10, 2010 1:55 PM
Trackback Pings
TrackBack URL for this entry:
http://guillaume.filion.org/blog/mt-tb.cgi/34
Comments
Post a comment
Thanks for signing in, . Now you can comment. (sign out)
(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)