5 $UnicodeData = "Unicode.301";
6 $SyllableData = "syllables.txt";
7 $PropData = "PropList.txt";
10 # Note: we try to keep filenames unique within first 8 chars. Using
11 # subdirectories for the following helps.
19 # 005F: SPACING UNDERSCROE
20 ['IsWord', '$cat =~ /^[LMN]/ or $code eq "005F"', ''],
21 ['IsAlnum', '$cat =~ /^[LMN]/', ''],
22 ['IsAlpha', '$cat =~ /^[LM]/', ''],
23 # 0009: HORIZONTAL TABULATION
25 # 000B: VERTICAL TABULATION
27 # 000D: CARRIAGE RETURN
29 ['IsSpace', '$cat =~ /^Z/ ||
30 $code =~ /^(0009|000A|000B|000C|000D)$/', ''],
33 $code =~ /^(0009|000A|000C|000D)$/', ''],
34 ['IsBlank', '$cat =~ /^Z[^lp]$/ || $code eq "0009"', ''],
35 ['IsDigit', '$cat =~ /^Nd$/', ''],
36 ['IsUpper', '$cat =~ /^L[ut]$/', ''],
37 ['IsLower', '$cat =~ /^Ll$/', ''],
38 ['IsASCII', '$code le "007f"', ''],
39 ['IsCntrl', '$cat =~ /^C/', ''],
40 ['IsGraph', '$cat =~ /^([LMNPS]|Co)/', ''],
41 ['IsPrint', '$cat =~ /^([LMNPS]|Co|Zs)/', ''],
42 ['IsPunct', '$cat =~ /^P/', ''],
43 # 003[0-9]: DIGIT ZERO..NINE, 00[46][1-6]: A..F, a..f
44 ['IsXDigit', '$code =~ /^00(3[0-9]|[46][1-6])$/', ''],
45 ['ToUpper', '$up', '$up'],
46 ['ToLower', '$down', '$down'],
47 ['ToTitle', '$title', '$title'],
48 ['ToDigit', '$dec ne ""', '$dec'],
52 ['Name', '$name', '$name'],
56 ['Category', '$cat', '$cat'],
60 ['IsM', '$cat =~ /^M/', ''], # Mark
61 ['IsMn', '$cat eq "Mn"', ''], # Mark, Non-Spacing
62 ['IsMc', '$cat eq "Mc"', ''], # Mark, Combining
63 ['IsMe', '$cat eq "Me"', ''], # Mark, Enclosing
65 ['IsN', '$cat =~ /^N/', ''], # Number
66 ['IsNd', '$cat eq "Nd"', ''], # Number, Decimal Digit
67 ['IsNo', '$cat eq "No"', ''], # Number, Other
68 ['IsNl', '$cat eq "Nl"', ''], # Number, Letter
70 ['IsZ', '$cat =~ /^Z/', ''], # Separator
71 ['IsZs', '$cat eq "Zs"', ''], # Separator, Space
72 ['IsZl', '$cat eq "Zl"', ''], # Separator, Line
73 ['IsZp', '$cat eq "Zp"', ''], # Separator, Paragraph
75 ['IsC', '$cat =~ /^C/', ''], # Crazy
76 ['IsCc', '$cat eq "Cc"', ''], # Other, Control or Format
77 ['IsCo', '$cat eq "Co"', ''], # Other, Private Use
78 ['IsCn', '$cat eq "Cn"', ''], # Other, Not Assigned
79 ['IsCf', '$cat eq "Cf"', ''], # Other, Format
80 ['IsCs', '$cat eq "Cs"', ''], # Other, Surrogate
81 ['IsCn', 'Unassigned Code Value',$PropData], # Other, Not Assigned
85 ['IsL', '$cat =~ /^L/', ''], # Letter
86 ['IsLu', '$cat eq "Lu"', ''], # Letter, Uppercase
87 ['IsLl', '$cat eq "Ll"', ''], # Letter, Lowercase
88 ['IsLt', '$cat eq "Lt"', ''], # Letter, Titlecase
89 ['IsLm', '$cat eq "Lm"', ''], # Letter, Modifier
90 ['IsLo', '$cat eq "Lo"', ''], # Letter, Other
92 ['IsP', '$cat =~ /^P/', ''], # Punctuation
93 ['IsPd', '$cat eq "Pd"', ''], # Punctuation, Dash
94 ['IsPs', '$cat eq "Ps"', ''], # Punctuation, Open
95 ['IsPe', '$cat eq "Pe"', ''], # Punctuation, Close
96 ['IsPo', '$cat eq "Po"', ''], # Punctuation, Other
97 ['IsPc', '$cat eq "Pc"', ''], # Punctuation, Connector
98 ['IsPi', '$cat eq "Pi"', ''], # Punctuation, Initial quote
99 ['IsPf', '$cat eq "Pf"', ''], # Punctuation, Final quote
101 ['IsS', '$cat =~ /^S/', ''], # Symbol
102 ['IsSm', '$cat eq "Sm"', ''], # Symbol, Math
103 ['IsSk', '$cat eq "Sk"', ''], # Symbol, Modifier
104 ['IsSc', '$cat eq "Sc"', ''], # Symbol, Currency
105 ['IsSo', '$cat eq "So"', ''], # Symbol, Other
108 ['CombiningClass', '$comb', '$comb'],
110 # BIDIRECTIONAL PROPERTIES
112 ['Bidirectional', '$bid', '$bid'],
116 ['IsBidiL', '$bid eq "L"', ''], # Left-Right; Most alphabetic,
117 # syllabic, and logographic
118 # characters (e.g., CJK
120 ['IsBidiR', '$bid eq "R"', ''], # Right-Left; Arabic, Hebrew,
121 # and punctuation specific to
124 ['IsBidiLRE', '$bid eq "LRE"', ''], # Left-to-Right Embedding
125 ['IsBidiLRO', '$bid eq "LRO"', ''], # Left-to-Right Override
126 ['IsBidiAL', '$bid eq "AL"', ''], # Right-to-Left Arabic
127 ['IsBidiRLE', '$bid eq "RLE"', ''], # Right-to-Left Embedding
128 ['IsBidiRLO', '$bid eq "RLO"', ''], # Right-to-Left Override
129 ['IsBidiPDF', '$bid eq "PDF"', ''], # Pop Directional Format
130 ['IsBidiNSM', '$bid eq "NSM"', ''], # Non-Spacing Mark
131 ['IsBidiBN', '$bid eq "BN"', ''], # Boundary Neutral
135 ['IsBidiEN','$bid eq "EN"', ''], # European Number
136 ['IsBidiES','$bid eq "ES"', ''], # European Number Separator
137 ['IsBidiET','$bid eq "ET"', ''], # European Number Terminator
138 ['IsBidiAN','$bid eq "AN"', ''], # Arabic Number
139 ['IsBidiCS','$bid eq "CS"', ''], # Common Number Separator
143 ['IsBidiB', '$bid eq "B"', ''], # Block Separator
144 ['IsBidiS', '$bid eq "S"', ''], # Segment Separator
148 ['IsBidiWS','$bid eq "WS"', ''], # Whitespace
149 ['IsBidiON','$bid eq "ON"', ''], # Other Neutrals ; All other
150 # characters: punctuation,
155 ['Decomposition', '$decomp', '$decomp'],
156 ['IsDecoCanon', '$decomp && $decomp !~ /^</', ''],
157 ['IsDecoCompat', '$decomp =~ /^</', ''],
158 ['IsDCfont', '$decomp =~ /^<font>/', ''],
159 ['IsDCnoBreak', '$decomp =~ /^<noBreak>/', ''],
160 ['IsDCinitial', '$decomp =~ /^<initial>/', ''],
161 ['IsDCmedial', '$decomp =~ /^<medial>/', ''],
162 ['IsDCfinal', '$decomp =~ /^<final>/', ''],
163 ['IsDCisolated', '$decomp =~ /^<isolated>/', ''],
164 ['IsDCcircle', '$decomp =~ /^<circle>/', ''],
165 ['IsDCsuper', '$decomp =~ /^<super>/', ''],
166 ['IsDCsub', '$decomp =~ /^<sub>/', ''],
167 ['IsDCvertical', '$decomp =~ /^<vertical>/', ''],
168 ['IsDCwide', '$decomp =~ /^<wide>/', ''],
169 ['IsDCnarrow', '$decomp =~ /^<narrow>/', ''],
170 ['IsDCsmall', '$decomp =~ /^<small>/', ''],
171 ['IsDCsquare', '$decomp =~ /^<square>/', ''],
172 ['IsDCfraction', '$decomp =~ /^<fraction>/', ''],
173 ['IsDCcompat', '$decomp =~ /^<compat>/', ''],
177 ['Number', '$num ne ""', '$num'],
181 ['IsMirrored', '$mir eq "Y"', ''],
185 ['ArabLink', '1', '$link'],
186 ['ArabLnkGrp', '1', '$linkgroup'],
190 ['JamoShort', '1', '$short'],
196 # Line break properties - Normative
198 ['IsLbrkBK','$brk eq "BK"', ''], # Mandatory Break
199 ['IsLbrkCR','$brk eq "CR"', ''], # Carriage Return
200 ['IsLbrkLF','$brk eq "LF"', ''], # Line Feed
201 ['IsLbrkCM','$brk eq "CM"', ''], # Attached Characters and Combining Marks
202 ['IsLbrkSG','$brk eq "SG"', ''], # Surrogates
203 ['IsLbrkGL','$brk eq "GL"', ''], # Non-breaking (Glue)
204 ['IsLbrkCB','$brk eq "CB"', ''], # Contingent Break Opportunity
205 ['IsLbrkSP','$brk eq "SP"', ''], # Space
206 ['IsLbrkZW','$brk eq "ZW"', ''], # Zero Width Space
208 # Line break properties - Informative
209 ['IsLbrkXX','$brk eq "XX"', ''], # Unknown
210 ['IsLbrkOP','$brk eq "OP"', ''], # Opening Punctuation
211 ['IsLbrkCL','$brk eq "CL"', ''], # Closing Punctuation
212 ['IsLbrkQU','$brk eq "QU"', ''], # Ambiguous Quotation
213 ['IsLbrkNS','$brk eq "NS"', ''], # Non Starter
214 ['IsLbrkEX','$brk eq "EX"', ''], # Exclamation/Interrogation
215 ['IsLbrkSY','$brk eq "SY"', ''], # Symbols Allowing Breaks
216 ['IsLbrkIS','$brk eq "IS"', ''], # Infix Separator (Numeric)
217 ['IsLbrkPR','$brk eq "PR"', ''], # Prefix (Numeric)
218 ['IsLbrkPO','$brk eq "PO"', ''], # Postfix (Numeric)
219 ['IsLbrkNU','$brk eq "NU"', ''], # Numeric
220 ['IsLbrkAL','$brk eq "AL"', ''], # Ordinary Alphabetic and Symbol Characters
221 ['IsLbrkID','$brk eq "ID"', ''], # Ideographic
222 ['IsLbrkIN','$brk eq "IN"', ''], # Inseparable
223 ['IsLbrkHY','$brk eq "HY"', ''], # Hyphen
224 ['IsLbrkBB','$brk eq "BB"', ''], # Break Opportunity Before
225 ['IsLbrkBA','$brk eq "BA"', ''], # Break Opportunity After
226 ['IsLbrkSA','$brk eq "SA"', ''], # Complex Context (South East Asian)
227 ['IsLbrkAI','$brk eq "AI"', ''], # Ambiguous (Alphabetic or Ideographic)
228 ['IsLbrkB2','$brk eq "B2"', ''], # Break Opportunity Before and After
231 # This is not written for speed...
233 foreach $file (@todo) {
234 my ($table, $wanted, $val) = @$file;
235 next if @ARGV and not grep { $_ eq $table } @ARGV;
237 if ($table =~ /^(Is|In|To)(.*)/) {
238 open(OUT, ">$1/$2.pl") or die "Can't create $1/$2.pl: $!\n";
241 open(OUT, ">$table.pl") or die "Can't create $table.pl: $!\n";
244 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
245 # This file is built by $0 from e.g. $UnicodeData.
246 # Any changes made here will be lost!
251 print OUT proplist($table, $wanted, $val);
256 # Must treat blocks specially.
258 exit if @ARGV and not grep { $_ eq Block } @ARGV;
260 open(UD, 'Blocks.txt') or die "Can't open Blocks.txt: $!\n";
261 open(OUT, ">Block.pl") or die "Can't create Block.pl: $!\n";
263 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
264 # This file is built by $0 from e.g. $UnicodeData.
265 # Any changes made here will be lost!
275 ($code, $last, $name) = split(/; */);
277 print OUT "$code $last $name\n";
279 open(BLOCK, ">In/$name.pl");
281 # !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
282 # This file is built by $0 from e.g. $UnicodeData.
283 # Any changes made here will be lost!
285 print BLOCK <<"END2";
297 ##################################################
300 my ($table, $wanted, $val) = @_;
305 return listFromPropFile($wanted) if $val eq $PropData;
307 if ($table =~ /^Arab/) {
308 open(UD, "ArabShap.txt") or warn "Can't open $table: $!";
310 $split = '($code, $name, $link, $linkgroup) = split(/; */);';
312 elsif ($table =~ /^Jamo/) {
313 open(UD, "Jamo.txt") or warn "Can't open $table: $!";
315 $split = '($code, $short, $name) = split(/; */); $code =~ s/^U\+//;';
317 elsif ($table =~ /^IsSyl/) {
318 open(UD, $SyllableData) or warn "Can't open $table: $!";
320 $split = '($code, $short, $syl) = split(/; */); $code =~ s/^U\+//;';
322 elsif ($table =~ /^IsLbrk/) {
323 open(UD, "LineBrk.txt") or warn "Can't open $table: $!";
325 $split = '($code, $brk, $name) = split(/;/);';
328 open(UD, $UnicodeData) or warn "Can't open $UnicodeData: $!";
330 $split = '($code, $name, $cat, $comb, $bid, $decomp, $dec, $dig, $num, $mir, $uni1,
331 $comment, $up, $down, $title) = split(/;/);';
334 if ($table =~ /^(?:To|Is)[A-Z]/) {
342 push(\@wanted, [hex \$code, hex $val, \$name =~ /, First>\$/]);
349 $beg = shift @wanted;
351 while (@wanted and $wanted[0]->[0] == $last->[0] + 1 and
352 (not $val or $wanted[0]->[1] == $last->[1] + 1)) {
353 $last = shift @wanted;
355 $out .= sprintf "%04x", $beg->[0];
357 $last = shift @wanted;
363 $out .= sprintf "\t%04x", $last->[0];
365 $out .= sprintf "\t%04x", $beg->[1] if $val;
377 push(\@wanted, [hex \$code, $val, \$name =~ /, First>\$/]);
384 $beg = shift @wanted;
386 while (@wanted and $wanted[0]->[0] == $last->[0] + 1 and
387 ($wanted[0]->[1] eq $last->[1])) {
388 $last = shift @wanted;
390 $out .= sprintf "%04x", $beg->[0];
392 $last = shift @wanted;
398 $out .= sprintf "\t%04x", $last->[0];
400 $out .= sprintf "\t%s\n", $beg->[1];
406 sub listFromPropFile {
410 open (UD, $PropData) or die "Can't open $PropData: $!\n";
411 local($/) = "\n" . '*' x 43 . "\n\nProperty dump for:"; # not 42?
416 if (s/0x[\d\w]+\s+\((.*?)\)// and $wanted eq $1) {
433 open (SD, $SyllableData) or die "Can't open $SyllableData: $!\n";
437 ($code, $name, $syl) = split /; */;
439 push (@defs, ["IsSyl$syl", qq{\$syl eq "$syl"}, ''])
440 unless $seen{$syl}++;