intl/uconv/tools/jis0212tojdx.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.

michael@0 1 #!/user/local/bin/perl
michael@0 2 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 5
michael@0 6 sub jis0212tonum()
michael@0 7 {
michael@0 8 my($jis0212) = (@_);
michael@0 9 my($first,$second,$jnum);
michael@0 10 $first = hex(substr($jis0212,2,2));
michael@0 11 $second = hex(substr($jis0212,4,2));
michael@0 12 $jnum = (($first - 0x21) * 94);
michael@0 13 $jnum += $second - 0x21 ;
michael@0 14 return $jnum;
michael@0 15 }
michael@0 16
michael@0 17 @map = {};
michael@0 18 sub readtable()
michael@0 19 {
michael@0 20 open(JIS0212, "<JIS0212") || die "cannot open JIS0212";
michael@0 21 while(<JIS0212>)
michael@0 22 {
michael@0 23 if(! /^#/) {
michael@0 24 ($j, $u, $r) = split(/\t/,$_);
michael@0 25 if(length($j) > 4)
michael@0 26 {
michael@0 27 $n = &jis0212tonum($j);
michael@0 28 $map{$n} = $u;
michael@0 29 }
michael@0 30 }
michael@0 31 }
michael@0 32 }
michael@0 33
michael@0 34 ## add eudc to $map here
michael@0 35
michael@0 36 sub printtable()
michael@0 37 {
michael@0 38 for($i=0;$i<94;$i++)
michael@0 39 {
michael@0 40 printf ( "/* 0x%2XXX */\n", ( $i + 0x21));
michael@0 41 printf " ";
michael@0 42 for($j=0;$j<94;$j++)
michael@0 43 {
michael@0 44 if("" == ($map{($i * 94 + $j)}))
michael@0 45 {
michael@0 46 print "0xFFFD,"
michael@0 47 }
michael@0 48 else
michael@0 49 {
michael@0 50 print $map{($i * 94 + $j)} . ",";
michael@0 51 }
michael@0 52 if( 7 == (($j + 1) % 8))
michael@0 53 {
michael@0 54 printf "/* 0x%2X%1X%1X*/\n", $i+0x21, 2+($j/16), (6==($j%16))?0:8;
michael@0 55 }
michael@0 56 }
michael@0 57 printf " /* 0x%2X%1X%1X*/\n", $i+0x21, 2+($j/16),(6==($j%16))?0:8;
michael@0 58 }
michael@0 59 }
michael@0 60 &readtable();
michael@0 61 &printtable();
michael@0 62

mercurial