]> mj.ucw.cz Git - libucw.git/blob - charset/misc/gen-unacc
Opt: Constify
[libucw.git] / charset / misc / gen-unacc
1 #!/usr/bin/perl
2 #
3 #  Create Unicode Unaccenting Table
4 #  (c) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
5 #
6
7 open (UNI, "unidata/UnicodeData.txt") || die "No Unicode Data File";
8 while (<UNI>) {
9     chomp;
10     ($num,$name,$cat,$_,$_,$exp) = split /;/;
11     if ($cat =~ /^L[ul]$/) { $letter{$num} = 1; }
12     if ($cat =~ /^Mn$/) { $accent{$num} = 1; }
13 }
14 close UNI;
15
16 open (UNI, "unidata/UnicodeData.txt") || die "No Unicode Data File";
17 while (<UNI>) {
18     chomp;
19     ($num,$name,$cat,$_,$_,$exp) = split /;/;
20     $num =~ /^....$/ || next;
21     if ($exp ne "") {
22         $exp =~ s/^<.*> *//g;
23         $good = 1;
24         $e = "";
25         foreach $a (split(/\s+/, $exp)) {
26             if ($accent{$a}) { }
27             elsif ($letter{$a}) {
28                 if ($e ne "") { $good = 0; }
29                 else { $e = $a; }
30             } else { $good = 0; }
31         }
32         if ($good && $e ne "") { print "$num\t0x$e\n"; }
33     }
34 }
35 close UNI;