ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent/util/gen_uts46data
(Generate patch)

Comparing AnyEvent/util/gen_uts46data (file contents):
Revision 1.8 by root, Sun Apr 24 22:16:28 2016 UTC vs.
Revision 1.10 by root, Wed Sep 30 07:48:47 2020 UTC

6use utf8; 6use utf8;
7no warnings 'utf8'; 7no warnings 'utf8';
8 8
9binmode STDOUT, ":utf8"; 9binmode STDOUT, ":utf8";
10 10
11open my $fh, "GET http://www.unicode.org/Public/idna/9.0.0/IdnaMappingTable.txt |" 11open my $fh, "GET http://www.unicode.org/Public/idna/13.0.0/IdnaMappingTable.txt |"
12 or die; 12 or die;
13 13
14my $valid; 14my $valid;
15my $imap; # index map \x00 char replacement 15my $imap; # index map \x00 char replacement
16 16
650 > index $imap, "\x02" # it's not supposed to be anywhere in there 650 > index $imap, "\x02" # it's not supposed to be anywhere in there
66 or die "imap contains \\x02"; 66 or die "imap contains \\x02";
67print $fh "\$uts46_imap = q\x02$imap\x00\x02;\n"; 67print $fh "\$uts46_imap = q\x02$imap\x00\x02;\n";
68 68
69# try to find a valid quoting character - there usually are many legal combos 69# try to find a valid quoting character - there usually are many legal combos
70for (1..127) { # stay out of utf-8 range 70for (33..112, 1..31) { # stay out of utf-8 range, prefer printable things
71 if (0 >= index $valid, chr) { 71 if (0 >= index $valid, chr) {
72 my $q = chr;
73
74 # primitive compression
75 $valid =~ s/(\x00{32,})/"$q.(\"\x00\"x" . (length $1) . ").$q"/ge;
76 $valid =~ s/(\xff{32,})/"$q.(\"\xff\"x" . (length $1) . ").$q"/ge;
77
72 print $fh "\$uts46_valid = q", chr, $valid, chr, ";\n"; 78 print $fh "\$uts46_valid = q$q$valid$q;\n";
73 goto valid_ok; 79 goto valid_ok;
74 } 80 }
75} 81}
76die "unable to found valid quoting character"; 82die "unable to found valid quoting character";
77valid_ok:; 83valid_ok:;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines