aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2011-05-16 19:34:35 +0930
committerMark Pulford <mark@kyne.com.au>2011-05-16 19:34:35 +0930
commit22550d0ab3328554922822ca0207996b3d1bb73e (patch)
treea9a752dbe907f94583e98294ff2501294e7a3a49
parenta966d2fd2aaff7651d7928fb8381a17bf1f5f517 (diff)
downloadlua-cjson-22550d0ab3328554922822ca0207996b3d1bb73e.tar.gz
lua-cjson-22550d0ab3328554922822ca0207996b3d1bb73e.tar.bz2
lua-cjson-22550d0ab3328554922822ca0207996b3d1bb73e.zip
Use Perl builtin UTF-8 support, not Text::Iconv
Remove Perl dependency on Text::Iconv to improve portability.
-rwxr-xr-xtests/genutf8.pl20
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/genutf8.pl b/tests/genutf8.pl
index 6a522dd..bbef91f 100755
--- a/tests/genutf8.pl
+++ b/tests/genutf8.pl
@@ -2,25 +2,31 @@
2 2
3# Create test comparison data using a different UTF-8 implementation. 3# Create test comparison data using a different UTF-8 implementation.
4 4
5# The generation utf8.dat file must have the following MD5 sum:
6# cff03b039d850f370a7362f3313e5268
7
5use strict; 8use strict;
6use warnings; 9use warnings;
7use Text::Iconv;
8use FileHandle; 10use FileHandle;
9 11
10# 0xD800 - 0xDFFF are used to encode supplementary codepoints 12# 0xD800 - 0xDFFF are used to encode supplementary codepoints
11# 0x10000 - 0x10FFFF are supplementary codepoints 13# 0x10000 - 0x10FFFF are supplementary codepoints
12my (@codepoints) = (0 .. 0xD7FF, 0xE000 .. 0x10FFFF); 14my (@codepoints) = (0 .. 0xD7FF, 0xE000 .. 0x10FFFF);
13 15
14my ($utf32be) = pack("N*", @codepoints); 16my ($utf8);
15my $iconv = Text::Iconv->new("UTF-32BE", "UTF-8"); 17{
16my ($utf8) = $iconv->convert($utf32be); 18 # Hide "Unicode character X is illegal" warnings.
19 # We want all the codes to test the UTF-8 escape decoder.
20 no warnings;
21 $utf8 = pack("U*", @codepoints);
22}
17defined($utf8) or die "Unable create UTF-8 string\n"; 23defined($utf8) or die "Unable create UTF-8 string\n";
18 24
19my $fh = FileHandle->new(); 25my $fh = FileHandle->new();
20$fh->open("utf8.dat", ">") 26$fh->open("utf8.dat", ">:utf8")
21 or die "Unable to open utf8.dat: $!\n"; 27 or die "Unable to open utf8.dat: $!\n";
22$fh->print($utf8) 28$fh->write($utf8)
23 or die "Unable to write utf.dat\n"; 29 or die "Unable to write utf8.dat\n";
24$fh->close(); 30$fh->close();
25 31
26# vi:ai et sw=4 ts=4: 32# vi:ai et sw=4 ts=4: