Annotation of parser3/src/main/helpers/simple_folding.pl, revision 1.2

1.1       paf         1: #      Parser: covertor of UNICODE casing data
                      2: #              http://www.unicode.org/Public/UNIDATA/CaseFolding.txt
                      3: #              to parser source code
                      4: #
1.2     ! moko        5: #      Copyright (c) 2003-2012 Art. Lebedev Studio (http://www.artlebedev.com)
1.1       paf         6: #      Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
                      7: 
1.2     ! moko        8: # $Id: simple_folding.pl,v 1.1 2003-09-29 09:42:12 paf Exp $
1.1       paf         9: 
                     10: #  usage:
                     11: #    download CaseFolding.txt
                     12: #    run simple_folding.pl < CaseFolding.txt
                     13: #
                     14: 
                     15: while(<>){
                     16:        chomp;
                     17:        # <code>; <status>; <mapping>; # <name>
                     18:        #1FAF; F; 1F67 03B9; # GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI
                     19:        my($code, $status, $mapping)=split /;\s*/;
                     20: 
                     21:        #we need only
                     22:        next if 
                     23:                $code eq ""
                     24:                || $code=~/^#/
                     25:                || $status eq 'F'
                     26:                || length($code)>4
                     27:                || length($mapping)>4;
                     28: #      print "$_\n";
                     29:        $toLower{$code}=$mapping unless defined $toLower{$code};
                     30:        $toUpper{$mapping}=$code unless defined $toUpper{$mapping};;
                     31: }
                     32: 
                     33: output(\%toLower, 'utf8-to-lower.inc');
                     34: output(\%toUpper, 'utf8-to-upper.inc');
                     35: 
                     36: sub output{
                     37:        my($tableRef, $name)=@_;
                     38:        open F, ">../$name";
                     39:        my($first)=1;
                     40:        my($counter)=0;
                     41:        foreach $key(sort {$a cmp $b} keys %$tableRef) {
                     42:                if(!$first){
                     43:                        print F ', ';
                     44:                }
                     45:                undef $first;
                     46:                if(++$counter>4) {
                     47:                        print F "\n";
                     48:                        $counter=1;
                     49:                }
                     50:                print F "{0x", $key, ", 0x", $tableRef->{$key}, "}";
                     51:        }
                     52:        print F "\n";
                     53:        close F;        
                     54: }

E-mail: