| Revision: | 1.2 |
| Committed: | Tue Sep 8 00:37:43 2009 UTC (17 years ago) by root |
| Content type: | application/x-troff |
| Branch: | MAIN |
| CVS Tags: | rel-2_3, rel-4_0, rel-3_0, rel-4_01, rel-4_03, rel-4_02, rel-4_04, rel-4_0_00, rel-2_34, rel-2_32, rel-2_33, rel-2_31, rel-3_01, rel-3_02, rel-3_03, rel-3_04, rel-2_29, rel-2_28, rel-2_27, rel-2_26, HEAD |
| Changes since 1.1: | +1 -1 lines |
| Log Message: | *** empty log message *** |
| # | Content |
|---|---|
| 1 | BEGIN { $| = 1; print "1..9\n"; } |
| 2 | |
| 3 | use utf8; |
| 4 | use JSON::XS; |
| 5 | |
| 6 | our $test; |
| 7 | sub ok($) { |
| 8 | print $_[0] ? "" : "not ", "ok ", ++$test, "\n"; |
| 9 | } |
| 10 | |
| 11 | ok (JSON::XS->new->allow_nonref (1)->utf8 (1)->encode ("ü") eq "\"\xc3\xbc\""); |
| 12 | ok (JSON::XS->new->allow_nonref (1)->encode ("ü") eq "\"ü\""); |
| 13 | ok (JSON::XS->new->allow_nonref (1)->ascii (1)->utf8 (1)->encode (chr 0x8000) eq '"\u8000"'); |
| 14 | ok (JSON::XS->new->allow_nonref (1)->ascii (1)->utf8 (1)->pretty (1)->encode (chr 0x10402) eq "\"\\ud801\\udc02\"\n"); |
| 15 | |
| 16 | eval { JSON::XS->new->allow_nonref (1)->utf8 (1)->decode ('"ü"') }; |
| 17 | ok $@ =~ /malformed UTF-8/; |
| 18 | |
| 19 | ok (JSON::XS->new->allow_nonref (1)->decode ('"ü"') eq "ü"); |
| 20 | ok (JSON::XS->new->allow_nonref (1)->decode ('"\u00fc"') eq "ü"); |
| 21 | ok (JSON::XS->new->allow_nonref (1)->decode ('"\ud801\udc02' . "\x{10204}\"") eq "\x{10402}\x{10204}"); |
| 22 | ok (JSON::XS->new->allow_nonref (1)->decode ('"\"\n\\\\\r\t\f\b"') eq "\"\012\\\015\011\014\010"); |
| 23 |