diff options
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: | ||
