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