Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^5: UTF8 fun and games again

by ultranerds (Pilgrim)
on Oct 17, 2011 at 18:37 UTC ( #931992=note: print w/ replies, xml ) Need Help??

in reply to Re^4: UTF8 fun and games again
in thread UTF8 fun and games again

Ok, for anyone interested - its cos the JSON module needed to explicitly use the utf8 functions JSON->new->utf8 , and then also decode(). I've changed it to this, and it works perfectly now <G>

sub Do_Translate { my ($from,$to,$string) = @_; my $url = "$k +ey&q=$string&source=$from&target=$to"; # print "getting URL: $url \n"; my $ua = LWP::UserAgent->new(); my $body = $ua->get($url); my $json = JSON->new->utf8; my $value = $json->decode( $body->decoded_content ); print "GOT: $value->{data}->{translations}[0]->{translatedText} \n +"; return utf8($value->{data}->{translations}[0]->{translatedText})-> +latin1; }

Comment on Re^5: UTF8 fun and games again
Download Code
Re^6: UTF8 fun and games again
by anneli (Pilgrim) on Oct 18, 2011 at 08:37 UTC

    Thanks for sharing your solution!


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://931992]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2015-04-26 08:59 GMT
Find Nodes?
    Voting Booth?

    Who makes your decisions?

    Results (485 votes), past polls