#!../../miniperl
-$UnicodeData = "UnicodeData-Latest.txt";
+$UnicodeData = "Unicode.300";
# Note: we try to keep filenames unique within first 8 chars. Using
# subdirectories for the following helps.
mkdir "In", 0777;
mkdir "Is", 0777;
mkdir "To", 0777;
-mkdir "Eq", 0777;
@todo = (
# typical
['IsSylWA', '$syl eq "A"', ''],
['IsSylWE', '$syl eq "E"', ''],
['IsSylWC', '$syl eq "C"', ''],
+
+# Line break properties - Normative
+
+ ['IsLbrkBK','$brk eq "BK"', ''], # Mandatory Break
+ ['IsLbrkCR','$brk eq "CR"', ''], # Carriage Return
+ ['IsLbrkLF','$brk eq "LF"', ''], # Line Feed
+ ['IsLbrkCM','$brk eq "CM"', ''], # Attached Characters and Combining Marks
+ ['IsLbrkSG','$brk eq "SG"', ''], # Surrogates
+ ['IsLbrkGL','$brk eq "GL"', ''], # Non-breaking (Glue)
+ ['IsLbrkCB','$brk eq "CB"', ''], # Contingent Break Opportunity
+ ['IsLbrkSP','$brk eq "SP"', ''], # Space
+ ['IsLbrkZW','$brk eq "ZW"', ''], # Zero Width Space
+
+# Line break properties - Informative
+ ['IsLbrkXX','$brk eq "XX"', ''], # Unknown
+ ['IsLbrkOP','$brk eq "OP"', ''], # Opening Punctuation
+ ['IsLbrkCL','$brk eq "CL"', ''], # Closing Punctuation
+ ['IsLbrkQU','$brk eq "QU"', ''], # Ambiguous Quotation
+ ['IsLbrkNS','$brk eq "NS"', ''], # Non Starter
+ ['IsLbrkEX','$brk eq "EX"', ''], # Exclamation/Interrogation
+ ['IsLbrkSY','$brk eq "SY"', ''], # Symbols Allowing Breaks
+ ['IsLbrkIS','$brk eq "IS"', ''], # Infix Separator (Numeric)
+ ['IsLbrkPR','$brk eq "PR"', ''], # Prefix (Numeric)
+ ['IsLbrkPO','$brk eq "PO"', ''], # Postfix (Numeric)
+ ['IsLbrkNU','$brk eq "NU"', ''], # Numeric
+ ['IsLbrkAL','$brk eq "AL"', ''], # Ordinary Alphabetic and Symbol Characters
+ ['IsLbrkID','$brk eq "ID"', ''], # Ideographic
+ ['IsLbrkIN','$brk eq "IN"', ''], # Inseparable
+ ['IsLbrkHY','$brk eq "HY"', ''], # Hyphen
+ ['IsLbrkBB','$brk eq "BB"', ''], # Break Opportunity Before
+ ['IsLbrkBA','$brk eq "BA"', ''], # Break Opportunity After
+ ['IsLbrkSA','$brk eq "SA"', ''], # Complex Context (South East Asian)
+ ['IsLbrkAI','$brk eq "AI"', ''], # Ambiguous (Alphabetic or Ideographic)
+ ['IsLbrkB2','$brk eq "B2"', ''], # Break Opportunity Before and After
);
# This is not written for speed...
else {
open(OUT, ">$table.pl") or die "Can't create $table.pl: $!\n";
}
+ print OUT <<EOH;
+# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
+# This file is built by $0 from e.g. $UnicodeData.
+# Any changes made here will be lost!
+EOH
print OUT <<"END";
return <<'END';
END
print "Block\n";
open(UD, 'Blocks.txt') or die "Can't open blocks.txt: $!\n";
open(OUT, ">Block.pl") or die "Can't create $table.pl: $!\n";
+print OUT <<EOH;
+# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
+# This file is built by $0 from e.g. $UnicodeData.
+# Any changes made here will be lost!
+EOH
print OUT <<"END";
return <<'END';
END
print OUT "$code $last $name\n";
$name =~ s/\s+//g;
open(BLOCK, ">In/$name.pl");
+ print BLOCK <<EOH;
+# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
+# This file is built by $0 from e.g. $UnicodeData.
+# Any changes made here will be lost!
+EOH
print BLOCK <<"END2";
return <<'END';
$code $last
$split = '($code, $name, $link, $linkgroup) = split(/; */);';
}
elsif ($table =~ /^Jamo/) {
- open(UD, "Jamo-2.txt") or warn "Can't open $table: $!";
+ open(UD, "Jamo.txt") or warn "Can't open $table: $!";
$split = '($code, $short, $name) = split(/; */); $code =~ s/^U\+//;';
}
$split = '($code, $short, $syl) = split(/; */); $code =~ s/^U\+//;';
}
+ elsif ($table =~ /^IsLbrk/) {
+ open(UD, "LineBrk.txt") or warn "Can't open $table: $!";
+
+ $split = '($code, $brk, $name) = split(/;/);';
+ }
else {
open(UD, $UnicodeData) or warn "Can't open $UnicodeData: $!";
$out;
}
-# Create the equivalence mappings.
-
-open(UNICODEDATA, $UnicodeData) || die "$0: $UnicodeData: $!\n";
-
-while (<UNICODEDATA>) {
- ($code, $name, $category, $decomposition) = (split /;/)[0,1,2,5];
-
- $code{$name} = $code;
- $name{$code} = $name;
- $category{$code} = $category;
-
- next unless $category =~ /^L/;
-
- # The definition of "equivalence" is twofold.
- if ($decomposition ne '') {
- # (1) If there's an official Unicode decomposition
- # and the base is a Unicode letter.
- $decomposition =~ s/^<\w+> //;
- @decomposition = split(' ', $decomposition);
- # Some Arabic ligatures like
- # FC5E;ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM;Lo;...
- # are problematic because their decomposition begins with
- # a space (0020) -- which could be just skipped -- but then
- # their base glyph is not a letter, for example
- # the above decomposes as <isolated> 0020 064C 0651,
- # but 064C is 064C;ARABIC DAMMATAN;Mn;...
- # (the 0651 being ARABIC SHADDA;Mn)
- ($basecode) = shift @decomposition;
- push @base, [ $code, $basecode ];
- } elsif ($name =~ /^(.+?) WITH /) {
- # (2) If there's a "FOO WITH ..." Unicode name and FOO
- # happens to be valid Unicode letter. This is
- # a debatable definition and all fault is by me (jhi).
- # For example this definition adds
- # LATIN SMALL LETTER O WITH STROKE
- # as a derivative of
- # LATIN SMALL LETTER O
- # which some might rightfully contest, especially
- # the speakers of languages who have the former
- # phonetically as very distinct from the latter.
- push @with, [ $code, $1 ];
- }
-}
-
-foreach my $w (@with) {
- ($code, $basename) = @$w;
- next if not exists $code{$basename} or
- not $category{$code{$basename}} =~ /^L/;
- push @base, [ $code, $code{$basename} ];
-}
-
-@base = sort { $a->[0] cmp $b->[0] } @base;
-
-foreach my $b (@base) {
- ($code, $basecode) = @$b;
- $basename = $name{$basecode};
- next if not defined $basename or
- not exists $code{$basename} or
- not $category{$code{$basename}} =~ /^L/;
- push @{$unicode{$code{$basename}}}, $code;
-# print "$code: $name{$code} -> $basename\n",
-}
-
-@unicode = sort keys %unicode;
-
-print "EqUnicode\n";
-if (open(EQ_UNICODE, ">Eq/Unicode")) {
- foreach my $c (@unicode) {
- print EQ_UNICODE "$c @{$unicode{$c}}\n";
- }
- close EQ_UNICODE;
-} else {
- die "$0: failed to open Eq/Unicode for writing: $!\n";
-}
-
-print "EqLatin1\n";
-if (open(EQ_LATIN1, ">Eq/Latin1")) {
- foreach my $c (@unicode) {
- last if hex($c) > 255;
- my @c = grep { hex($_) < 256 } @{$unicode{$c}};
- next unless @c;
- print EQ_LATIN1 "$c @c\n";
- }
- close EQ_LATIN1;
-} else {
- die "$0: failed to open Eq/Latin1 for writing: $!\n";
-}
-
# eof