1use strict; 2use Test::More tests => 3; 3use Cpanel::JSON::XS; 4 5BEGIN { 6 use lib qw(t); 7 use _unicode_handling; 8} 9 10my $json = Cpanel::JSON::XS->new->allow_nonref->utf8; 11my $str = '\\u00c8'; 12 13my $value = $json->decode( '"\\u00c8"' ); 14 15#use Devel::Peek; 16#Dump( $value ); 17 18is( $value, chr 0xc8 ); 19 20SKIP: { 21 skip "UNICODE handling is disabled.", 1 unless $] >= 5.008001 and $JSON::can_handle_UTF16_and_utf8; 22 ok( utf8::is_utf8( $value ) ); 23} 24 25eval { $json->decode( '"' . chr(0xc8) . '"' ) }; 26ok( $@ =~ /malformed UTF-8 character in JSON string/ ); 27 28