intl/uconv/tools/unihan2cns.pl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 #!/usr/local/bin/perl -w
     2 # This Source Code Form is subject to the terms of the Mozilla Public
     3 # License, v. 2.0. If a copy of the MPL was not distributed with this
     4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     6 use IO::File;
     7 my(%tagtofilemap);
     8 $tagtofilemap{"kCNS1986-1" } = IO::File->new("|sort> cns1986p1.txt")  
     9       or die "cannot open cns1986p1.txt";
    10 $tagtofilemap{"kCNS1986-2" } = IO::File->new("|sort> cns1986p2.txt")  
    11       or die "cannot open cns1986p2.txt";
    12 $tagtofilemap{"kCNS1986-E" } = IO::File->new("|sort> cns1986p14.txt") 
    13       or die "cannot open cns1986p14.txt"; 
    14 $tagtofilemap{"kCNS1992-1" } = IO::File->new("|sort> cns1992p1.txt")  
    15       or die "cannot open cns1992p1.txt"; 
    16 $tagtofilemap{"kCNS1992-2" } = IO::File->new("|sort> cns1992p2.txt") 
    17       or die "cannot open cns1992p2.txt"; 
    18 $tagtofilemap{"kCNS1992-3" } = IO::File->new("|sort> cns1992p3.txt") 
    19       or die "cannot open cns1992p3.txt"; 
    20 $tagtofilemap{"kIRG_TSource-1" } = IO::File->new("|sort> cnsIRGTp1.txt") 
    21       or die "cannot open cnsIRGTp1.txt"; 
    22 $tagtofilemap{"kIRG_TSource-2" } = IO::File->new("|sort> cnsIRGTp2.txt") 
    23       or die "cannot open cnsIRGTp2.txt"; 
    24 $tagtofilemap{"kIRG_TSource-3" } = IO::File->new("|sort> cnsIRGTp3.txt") 
    25       or die "cannot open cnsIRGTp3.txt"; 
    26 $tagtofilemap{"kIRG_TSource-4" } = IO::File->new("|sort> cnsIRGTp4.txt") 
    27       or die "cannot open cnsIRGTp4.txt"; 
    28 $tagtofilemap{"kIRG_TSource-5" } = IO::File->new("|sort> cnsIRGTp5.txt") 
    29       or die "cannot open cnsIRGTp5.txt"; 
    30 $tagtofilemap{"kIRG_TSource-6" } = IO::File->new("|sort> cnsIRGTp6.txt") 
    31       or die "cannot open cnsIRGTp6.txt"; 
    32 $tagtofilemap{"kIRG_TSource-7" } = IO::File->new("|sort> cnsIRGTp7.txt") 
    33       or die "cannot open cnsIRGTp7.txt"; 
    34 $tagtofilemap{"kIRG_TSource-F" } = IO::File->new("|sort> cnsIRGTp15.txt") 
    35       or die "cannot open cnsIRGTp15.txt";
    36 $tagtofilemap{"kIRG_TSource-3ExtB" } = IO::File->new("|sort> cnsIRGTp3ExtB.txt") 
    37       or die "cannot open cnsIRGTp3ExtB.txt"; 
    38 $tagtofilemap{"kIRG_TSource-4ExtB" } = IO::File->new("|sort> cnsIRGTp4ExtB.txt") 
    39       or die "cannot open cnsIRGTp4ExtB.txt"; 
    40 $tagtofilemap{"kIRG_TSource-5ExtB" } = IO::File->new("|sort> cnsIRGTp5ExtB.txt") 
    41       or die "cannot open cnsIRGTp5ExtB.txt"; 
    42 $tagtofilemap{"kIRG_TSource-6ExtB" } = IO::File->new("|sort> cnsIRGTp6ExtB.txt") 
    43       or die "cannot open cnsIRGTp6ExtB.txt"; 
    44 $tagtofilemap{"kIRG_TSource-7ExtB" } = IO::File->new("|sort> cnsIRGTp7ExtB.txt") 
    45       or die "cannot open cnsIRGTp7ExtB.txt"; 
    46 $tagtofilemap{"kIRG_TSource-FExtB" } = IO::File->new("|sort> cnsIRGTp15ExtB.txt") 
    47       or die "cannot open cnsIRGTp15ExtB.txt";
    49 $nonhan =  IO::File->new("< nonhan.txt") 
    50       or die "cannot open nonhan.txt";
    52 while(defined($line = $nonhan->getline()))
    53 {
    54    $tagtofilemap{"kCNS1986-1"}->print($line);
    55    $tagtofilemap{"kCNS1992-1"}->print($line);
    56    $tagtofilemap{"kIRG_TSource-1"}->print($line);
    57 }
    59 while(<STDIN>)
    60 {
    61   if(/^U/)
    62   {
    63     chop();
    64     ($u,$tag,$value) = split(/\t/,$_);
    65     if($tag =~ m/(kCNS|kIRG_TSource)/)
    66     {
    67          ($pnum, $cvalue) = split(/-/,$value);
    68          $tagkey = $tag . "-" . $pnum;
    69          if(length($u) > 6) {
    70            $tagkey .= "ExtB";
    71          }
    72          $fd = $tagtofilemap{$tagkey};
    73          if(length($u) > 6) {
    74            $mapping = substr($u,3,4); # trunkcate 0x2 from 0x2abcd
    75          } else {
    76            $mapping = substr($u,2,4); # trunkcate 0x from 0xabcd
    77          }
    78          $fd->print("0x" . $cvalue . "\t0x" . $mapping . "\t# <CJK>\n");
    79     }
    80   }
    81 }

mercurial