3 $UnicodeData = "UnicodeData-Latest.txt";
5 # Note: we try to keep filenames unique within first 8 chars. Using
6 # subdirectories for the following helps.
15 ['IsWord', '$cat =~ /^L[ulo]|^Nd/ or $code eq "005F"', ''],
16 ['IsAlnum', '$cat =~ /^L[ulo]|^Nd/', ''],
17 ['IsAlpha', '$cat =~ /^L[ulo]/', ''],
18 ['IsSpace', '$cat =~ /^Z/ or $code lt "0020" and chr(hex $code) =~ /^\s/', ''],
19 ['IsDigit', '$cat =~ /^Nd$/', ''],
20 ['IsUpper', '$cat =~ /^Lu$/', ''],
21 ['IsLower', '$cat =~ /^Ll$/', ''],
22 ['IsASCII', 'hex $code <= 127', ''],
23 ['IsCntrl', '$cat =~ /^C/', ''],
24 ['IsGraph', '$cat =~ /^[^C]/ and $code ne "0020"', ''],
25 ['IsPrint', '$cat =~ /^[^C]/', ''],
26 ['IsPunct', '$cat =~ /^P/', ''],
27 ['IsXDigit', '$code =~ /^00(3[0-9]|[46][1-6])$/', ''],
28 ['ToUpper', '$up', '$up'],
29 ['ToLower', '$down', '$down'],
30 ['ToTitle', '$title', '$title'],
31 ['ToDigit', '$dec ne ""', '$dec'],
35 ['Name', '$name', '$name'],
39 ['Category', '$cat', '$cat'],
43 ['IsM', '$cat =~ /^M/', ''], # Mark
44 ['IsMn', '$cat eq "Mn"', ''], # Mark, Non-Spacing
45 ['IsMc', '$cat eq "Mc"', ''], # Mark, Combining
47 ['IsN', '$cat =~ /^N/', ''], # Number
48 ['IsNd', '$cat eq "Nd"', ''], # Number, Decimal Digit
49 ['IsNo', '$cat eq "No"', ''], # Number, Other
51 ['IsZ', '$cat =~ /^Z/', ''], # Zeparator
52 ['IsZs', '$cat eq "Zs"', ''], # Separator, Space
53 ['IsZl', '$cat eq "Zl"', ''], # Separator, Line
54 ['IsZp', '$cat eq "Zp"', ''], # Separator, Paragraph
56 ['IsC', '$cat =~ /^C/', ''], # Crazy
57 ['IsCc', '$cat eq "Cc"', ''], # Other, Control or Format
58 ['IsCo', '$cat eq "Co"', ''], # Other, Private Use
59 ['IsCn', '$cat eq "Cn"', ''], # Other, Not Assigned
63 ['IsL', '$cat =~ /^L/', ''], # Letter
64 ['IsLu', '$cat eq "Lu"', ''], # Letter, Uppercase
65 ['IsLl', '$cat eq "Ll"', ''], # Letter, Lowercase
66 ['IsLt', '$cat eq "Lt"', ''], # Letter, Titlecase
67 ['IsLm', '$cat eq "Lm"', ''], # Letter, Modifier
68 ['IsLo', '$cat eq "Lo"', ''], # Letter, Other
70 ['IsP', '$cat =~ /^P/', ''], # Punctuation
71 ['IsPd', '$cat eq "Pd"', ''], # Punctuation, Dash
72 ['IsPs', '$cat eq "Ps"', ''], # Punctuation, Open
73 ['IsPe', '$cat eq "Pe"', ''], # Punctuation, Close
74 ['IsPo', '$cat eq "Po"', ''], # Punctuation, Other
76 ['IsS', '$cat =~ /^S/', ''], # Symbol
77 ['IsSm', '$cat eq "Sm"', ''], # Symbol, Math
78 ['IsSc', '$cat eq "Sc"', ''], # Symbol, Currency
79 ['IsSo', '$cat eq "So"', ''], # Symbol, Other
82 ['CombiningClass', '$comb', '$comb'],
84 # BIDIRECTIONAL PROPERTIES
86 ['Bidirectional', '$bid', '$bid'],
90 ['IsBidiL', '$bid eq "L"', ''], # Left-Right; Most alphabetic,
91 # syllabic, and logographic
92 # characters (e.g., CJK
94 ['IsBidiR', '$bid eq "R"', ''], # Right-Left; Arabic, Hebrew,
95 # and punctuation specific to
100 ['IsBidiEN','$bid eq "EN"', ''], # European Number
101 ['IsBidiES','$bid eq "ES"', ''], # European Number Separator
102 ['IsBidiET','$bid eq "ET"', ''], # European Number Terminator
103 ['IsBidiAN','$bid eq "AN"', ''], # Arabic Number
104 ['IsBidiCS','$bid eq "CS"', ''], # Common Number Separator
108 ['IsBidiB', '$bid eq "B"', ''], # Block Separator
109 ['IsBidiS', '$bid eq "S"', ''], # Segment Separator
113 ['IsBidiWS','$bid eq "WS"', ''], # Whitespace
114 ['IsBidiON','$bid eq "ON"', ''], # Other Neutrals ; All other
115 # characters: punctuation,
120 ['Decomposition', '$decomp', '$decomp'],
121 ['IsDecoCanon', '$decomp && $decomp !~ /^</', ''],
122 ['IsDecoCompat', '$decomp =~ /^</', ''],
123 ['IsDCfont', '$decomp =~ /^<font>/', ''],
124 ['IsDCnoBreak', '$decomp =~ /^<noBreak>/', ''],
125 ['IsDCinitial', '$decomp =~ /^<initial>/', ''],
126 ['IsDCinital', '$decomp =~ /^<medial>/', ''],
127 ['IsDCfinal', '$decomp =~ /^<final>/', ''],
128 ['IsDCisolated', '$decomp =~ /^<isolated>/', ''],
129 ['IsDCcircle', '$decomp =~ /^<circle>/', ''],
130 ['IsDCsuper', '$decomp =~ /^<super>/', ''],
131 ['IsDCsub', '$decomp =~ /^<sub>/', ''],
132 ['IsDCvertical', '$decomp =~ /^<vertical>/', ''],
133 ['IsDCwide', '$decomp =~ /^<wide>/', ''],
134 ['IsDCnarrow', '$decomp =~ /^<narrow>/', ''],
135 ['IsDCsmall', '$decomp =~ /^<small>/', ''],
136 ['IsDCsquare', '$decomp =~ /^<square>/', ''],
137 ['IsDCcompat', '$decomp =~ /^<compat>/', ''],
141 ['Number', '$num', '$num'],
145 ['IsMirrored', '$mir eq "Y"', ''],
149 ['ArabLink', '1', '$link'],
150 ['ArabLnkGrp', '1', '$linkgroup'],
154 ['JamoShort', '1', '$short'],
158 ['IsSylV', '$syl eq "V"', ''],
159 ['IsSylU', '$syl eq "U"', ''],
160 ['IsSylI', '$syl eq "I"', ''],
161 ['IsSylA', '$syl eq "A"', ''],
162 ['IsSylE', '$syl eq "E"', ''],
163 ['IsSylC', '$syl eq "C"', ''],
164 ['IsSylO', '$syl eq "O"', ''],
165 ['IsSylWV', '$syl eq "V"', ''],
166 ['IsSylWI', '$syl eq "I"', ''],
167 ['IsSylWA', '$syl eq "A"', ''],
168 ['IsSylWE', '$syl eq "E"', ''],
169 ['IsSylWC', '$syl eq "C"', ''],
172 # This is not written for speed...
174 foreach $file (@todo) {
175 my ($table, $wanted, $val) = @$file;
176 next if @ARGV and not grep { $_ eq $table } @ARGV;
178 if ($table =~ /^(Is|In|To)(.*)/) {
179 open(OUT, ">$1/$2.pl") or die "Can't create $1/$2.pl: $!\n";
182 open(OUT, ">$table.pl") or die "Can't create $table.pl: $!\n";
187 print OUT proplist($table, $wanted, $val);
192 # Must treat blocks specially.
194 exit if @ARGV and not grep { $_ eq Block } @ARGV;
196 open(UD, 'blocks.txt') or die "Can't open blocks.txt: $!\n";
197 open(OUT, ">Block.pl") or die "Can't create $table.pl: $!\n";
206 ($code, $last, $name) = split(/; */);
208 print OUT "$code $last $name\n";
210 open(BLOCK, ">In/$name.pl");
211 print BLOCK <<"END2";
223 ##################################################
226 my ($table, $wanted, $val) = @_;
231 if ($table =~ /^Arab/) {
232 open(UD, "arabshp.txt") or warn "Can't open $table: $!";
234 $split = '($code, $name, $link, $linkgroup) = split(/; */);';
236 elsif ($table =~ /^Jamo/) {
237 open(UD, "jamo2.txt") or warn "Can't open $table: $!";
239 $split = '($code, $short, $name) = split(/; */); $code =~ s/^U\+//;';
241 elsif ($table =~ /^IsSyl/) {
242 open(UD, "syllables.txt") or warn "Can't open $table: $!";
244 $split = '($code, $short, $syl) = split(/; */); $code =~ s/^U\+//;';
247 open(UD, $UnicodeData) or warn "Can't open $UnicodeData: $!";
249 $split = '($code, $name, $cat, $comb, $bid, $decomp, $dec, $dig, $num, $mir, $uni1,
250 $comment, $up, $down, $title) = split(/;/);';
253 if ($table =~ /^(?:To|Is)[A-Z]/) {
261 push(\@wanted, [hex \$code, hex $val, \$name =~ /, First>\$/]);
268 $beg = shift @wanted;
270 while (@wanted and $wanted[0]->[0] == $last->[0] + 1 and
271 (not $val or $wanted[0]->[1] == $last->[1] + 1)) {
272 $last = shift @wanted;
274 $out .= sprintf "%04x", $beg->[0];
276 $last = shift @wanted;
282 $out .= sprintf "\t%04x", $last->[0];
284 $out .= sprintf "\t%04x", $beg->[1] if $val;
296 push(\@wanted, [hex \$code, $val, \$name =~ /, First>\$/]);
303 $beg = shift @wanted;
305 while (@wanted and $wanted[0]->[0] == $last->[0] + 1 and
306 ($wanted[0]->[1] eq $last->[1])) {
307 $last = shift @wanted;
309 $out .= sprintf "%04x", $beg->[0];
311 $last = shift @wanted;
317 $out .= sprintf "\t%04x", $last->[0];
319 $out .= sprintf "\t%s\n", $beg->[1];
325 # Create the equivalence mappings.
327 open(UNICODEDATA, $UnicodeData) || die "$0: $UnicodeData: $!\n";
329 while (<UNICODEDATA>) {
330 ($code, $name) = split /;/;
332 $code{$name} = $code;
333 $name{$code} = $name;
335 next unless $name =~ /^(.+? LETTER .+?) WITH .+( \w+ FORM)?$/;
337 push @base, [ $code, $1 ];
338 push @base, [ $code, $1.$2 ] if $2 ne '';
341 foreach my $b (@base) {
342 ($code, $base) = @$b;
343 next unless exists $code{$base};
344 push @{$unicode{$code{$base}}}, $code;
345 # print "$code: $name{$code} -> $base\n",
348 @unicode = sort keys %unicode;
350 print "Eq/Unicode\n";
351 if (open(EQ_UNICODE, ">Eq/Unicode")) {
352 foreach my $c (@unicode) {
353 print EQ_UNICODE "$c @{$unicode{$c}}\n";
357 die "$0: failed to open Eq/Unicode for writing: $!\n";
361 if (open(EQ_LATIN1, ">Eq/Latin1")) {
362 foreach my $c (@unicode) {
363 last if hex($c) > 255;
364 my @c = grep { hex($_) <= 255 } @{$unicode{$c}};
366 print EQ_LATIN1 "$c @c\n";
370 die "$0: failed to open Eq/Latin1 for writing: $!\n";