intl/uconv/tools/jis0212tojdx.pl
author Jacob Bramley <Jacob.Bramley@arm.com>
Tue, 17 Aug 2010 15:19:31 +0100
changeset 53443 88150a1222bc9d922967a5b37ec19d214e10e702
parent 1 9b2a99adc05e53cd4010de512f50118594756650
child 98529 f4157e8c410708d76703f19e4dfb61859bfe32d8
permissions -rw-r--r--
[JAEGER] Fix ARM's long-range loads. [No bug] [r=me]

#!/user/local/bin/perl
sub jis0212tonum()
{
   my($jis0212) = (@_);
   my($first,$second,$jnum);
   $first = hex(substr($jis0212,2,2));
   $second = hex(substr($jis0212,4,2));
   $jnum = (($first - 0x21) * 94);
   $jnum += $second - 0x21 ;
   return $jnum;
}

@map = {};
sub readtable()
{
open(JIS0212, "<JIS0212") || die "cannot open JIS0212";
while(<JIS0212>)
{
   if(! /^#/) {
        ($j, $u, $r) = split(/\t/,$_);
        if(length($j) > 4)
        {
        $n = &jis0212tonum($j);
        $map{$n} = $u;
        }
   } 
}
}

## add eudc to  $map here

sub printtable()
{
for($i=0;$i<94;$i++)
{
     printf ( "/* 0x%2XXX */\n", ( $i + 0x21));
     printf "       ";
     for($j=0;$j<94;$j++)
     {
         if("" == ($map{($i * 94 + $j)}))
         {
            print "0xFFFD,"
         } 
         else 
         {   
            print $map{($i * 94 + $j)} . ",";
         }
         if( 7 == (($j + 1) % 8))
         {
            printf "/* 0x%2X%1X%1X*/\n", $i+0x21, 2+($j/16), (6==($j%16))?0:8;
         }
     }
     printf "       /* 0x%2X%1X%1X*/\n", $i+0x21, 2+($j/16),(6==($j%16))?0:8;
}
}
&readtable();
&printtable();