aboutsummaryrefslogtreecommitdiff
path: root/tests/genutf8.pl
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2011-05-08 20:26:09 +0930
committerMark Pulford <mark@kyne.com.au>2011-05-08 20:26:09 +0930
commit4dc56c6d362f2cd8a79d83369f0b852df07dae3f (patch)
treed51d3470a396c7981871b4f6fe4fd331e180db83 /tests/genutf8.pl
parenteeebeda88e62fefa87c71d616d5719782bdaa45a (diff)
downloadlua-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 'tests/genutf8.pl')
-rwxr-xr-xtests/genutf8.pl25
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
5use strict;
6use Text::Iconv;
7use FileHandle;
8
9# 0xD800 - 0xDFFF are used to encode supplementary codepoints
10# 0x10000 - 0x10FFFF are supplementary codepoints
11my (@codepoints) = (0 .. 0xD7FF, 0xE000 .. 0x10FFFF);
12
13my ($utf32be) = pack("N*", @codepoints);
14my $iconv = Text::Iconv->new("UTF-32BE", "UTF-8");
15my ($utf8) = $iconv->convert($utf32be);
16defined($utf8) or die "Unable create UTF-8 string\n";
17
18my $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: