1# 2# decode on Perl 5.005, 5.6, 5.8 or later 3# 4use strict; 5use warnings; 6use Test::More; 7 8BEGIN { plan tests => 6 }; 9 10BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } 11 12use JSON::PP; 13 14no utf8; 15 16my $json = JSON::PP->new->allow_nonref; 17 18 19is($json->decode(q|"ü"|), "ü"); # utf8 20is($json->decode(q|"\u00fc"|), "\xfc"); # latin1 21is($json->decode(q|"\u00c3\u00bc"|), "\xc3\xbc"); # utf8 22 23my $str = 'あ'; # Japanese 'a' in utf8 24 25is($json->decode(q|"\u00e3\u0081\u0082"|), $str); 26 27utf8::decode($str); # usually UTF-8 flagged on, but no-op for 5.005. 28 29is($json->decode(q|"\u3042"|), $str); 30 31 32my $utf8 = $json->decode(q|"\ud808\udf45"|); # chr 12345 33 34utf8::encode($utf8); # UTF-8 flagged off 35 36is($utf8, "\xf0\x92\x8d\x85"); 37 38