slugger415 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have a simple JSON query (to Facebook events) that contains smart quotes and other special characters that render badly in the browser. I've tried utf8::encode on the relevant field but that seems to wipe it out completely (it returns nothing).
code snippet:
use JSON qw( decode_json ); use LWP::Simple; use utf8; use strict; my($url) = "https://graph.facebook.com/$id?access_token=" . $token; my($json) = get($url); my($decoded) = decode_json($json); $event{'desc'} = utf8::decode($decoded->{'description'});
Without the utf8::decode I get all the description but with bad character rendering, e.g. "Action Films" (with smart quotes) looks like:
“Action filmsâ€But again, the utf8::decode seems to wipe it out.
thanks, Scott
|
---|
Back to
Seekers of Perl Wisdom