diff options
| author | Mark Pulford <mark@kyne.com.au> | 2011-05-08 20:26:09 +0930 |
|---|---|---|
| committer | Mark Pulford <mark@kyne.com.au> | 2011-05-08 20:26:09 +0930 |
| commit | 4dc56c6d362f2cd8a79d83369f0b852df07dae3f (patch) | |
| tree | d51d3470a396c7981871b4f6fe4fd331e180db83 /tests/genutf8.pl | |
| parent | eeebeda88e62fefa87c71d616d5719782bdaa45a (diff) | |
| download | lua-cjson-4dc56c6d362f2cd8a79d83369f0b852df07dae3f.tar.gz lua-cjson-4dc56c6d362f2cd8a79d83369f0b852df07dae3f.tar.bz2 lua-cjson-4dc56c6d362f2cd8a79d83369f0b852df07dae3f.zip | |
Add UTF-16 surrogate pair decode support
- Add tests for UTF-16 decoding and failures
- Add getutf8.pl to assist with UTF-16 decode testing
- Re-add test_decode_cycle() which was accidentally removed earlier
- Rename bytestring.dat to octets-escaped.dat
Diffstat (limited to '')
| -rwxr-xr-x | tests/genutf8.pl | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/genutf8.pl b/tests/genutf8.pl new file mode 100755 index 0000000..4960663 --- /dev/null +++ b/tests/genutf8.pl | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #!/usr/bin/perl -w | ||
| 2 | |||
| 3 | # Create test comparison data using a different UTF-8 implementation. | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use Text::Iconv; | ||
| 7 | use FileHandle; | ||
| 8 | |||
| 9 | # 0xD800 - 0xDFFF are used to encode supplementary codepoints | ||
| 10 | # 0x10000 - 0x10FFFF are supplementary codepoints | ||
| 11 | my (@codepoints) = (0 .. 0xD7FF, 0xE000 .. 0x10FFFF); | ||
| 12 | |||
| 13 | my ($utf32be) = pack("N*", @codepoints); | ||
| 14 | my $iconv = Text::Iconv->new("UTF-32BE", "UTF-8"); | ||
| 15 | my ($utf8) = $iconv->convert($utf32be); | ||
| 16 | defined($utf8) or die "Unable create UTF-8 string\n"; | ||
| 17 | |||
| 18 | my $fh = FileHandle->new(); | ||
| 19 | $fh->open("utf8.dat", ">") | ||
| 20 | or die "Unable to open utf8.dat: $!\n"; | ||
| 21 | $fh->print($utf8) | ||
| 22 | or die "Unable to write utf.dat\n"; | ||
| 23 | $fh->close(); | ||
| 24 | |||
| 25 | # vi:ai et sw=4 ts=4: | ||
