aboutsummaryrefslogtreecommitdiff
path: root/tests/genutf8.pl
diff options
context:
space:
mode:
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: