genutf8.pl 685 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/perl -w
  2. # Create test comparison data using a different UTF-8 implementation.
  3. use strict;
  4. use Text::Iconv;
  5. use FileHandle;
  6. # 0xD800 - 0xDFFF are used to encode supplementary codepoints
  7. # 0x10000 - 0x10FFFF are supplementary codepoints
  8. my (@codepoints) = (0 .. 0xD7FF, 0xE000 .. 0x10FFFF);
  9. my ($utf32be) = pack("N*", @codepoints);
  10. my $iconv = Text::Iconv->new("UTF-32BE", "UTF-8");
  11. my ($utf8) = $iconv->convert($utf32be);
  12. defined($utf8) or die "Unable create UTF-8 string\n";
  13. my $fh = FileHandle->new();
  14. $fh->open("utf8.dat", ">")
  15. or die "Unable to open utf8.dat: $!\n";
  16. $fh->print($utf8)
  17. or die "Unable to write utf.dat\n";
  18. $fh->close();
  19. # vi:ai et sw=4 ts=4: