1# 2# decode on Perl 5.005, 5.6, 5.8 or later 3# 4use strict; 5use Test::More; 6 7BEGIN { plan tests => 7 }; 8 9BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; } 10 11use JSON; 12 13BEGIN { 14 use lib qw(t); 15 use _unicode_handling; 16} 17 18no utf8; 19 20my $json = JSON->new->allow_nonref; 21 22is($json->encode("ü"), q|"ü"|); # as is 23 24$json->ascii; 25 26is($json->encode("\xfc"), q|"\u00fc"|); # latin1 27is($json->encode("\xc3\xbc"), q|"\u00c3\u00bc"|); # utf8 28is($json->encode("ü"), q|"\u00c3\u00bc"|); # utf8 29is($json->encode('あ'), q|"\u00e3\u0081\u0082"|); 30 31if ($] >= 5.006) { 32 is($json->encode(chr hex 3042 ), q|"\u3042"|); 33 is($json->encode(chr hex 12345 ), q|"\ud808\udf45"|); 34} 35else { 36 is($json->encode(chr hex 3042 ), $json->encode(chr 66)); 37 is($json->encode(chr hex 12345 ), $json->encode(chr 69)); 38} 39 40