genutf8.pl 849 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env perl
  2. # Create test comparison data using a different UTF-8 implementation.
  3. # The generation utf8.dat file must have the following MD5 sum:
  4. # cff03b039d850f370a7362f3313e5268
  5. use strict;
  6. use warnings;
  7. use FileHandle;
  8. # 0xD800 - 0xDFFF are used to encode supplementary codepoints
  9. # 0x10000 - 0x10FFFF are supplementary codepoints
  10. my (@codepoints) = (0 .. 0xD7FF, 0xE000 .. 0x10FFFF);
  11. my ($utf8);
  12. {
  13. # Hide "Unicode character X is illegal" warnings.
  14. # We want all the codes to test the UTF-8 escape decoder.
  15. no warnings;
  16. $utf8 = pack("U*", @codepoints);
  17. }
  18. defined($utf8) or die "Unable create UTF-8 string\n";
  19. my $fh = FileHandle->new();
  20. $fh->open("utf8.dat", ">:utf8")
  21. or die "Unable to open utf8.dat: $!\n";
  22. $fh->write($utf8)
  23. or die "Unable to write utf8.dat\n";
  24. $fh->close();
  25. # vi:ai et sw=4 ts=4: