michael@0: #!/user/local/bin/perl michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: sub jis0212tonum() michael@0: { michael@0: my($jis0212) = (@_); michael@0: my($first,$second,$jnum); michael@0: $first = hex(substr($jis0212,2,2)); michael@0: $second = hex(substr($jis0212,4,2)); michael@0: $jnum = (($first - 0x21) * 94); michael@0: $jnum += $second - 0x21 ; michael@0: return $jnum; michael@0: } michael@0: michael@0: @map = {}; michael@0: sub readtable() michael@0: { michael@0: open(JIS0212, ") michael@0: { michael@0: if(! /^#/) { michael@0: ($j, $u, $r) = split(/\t/,$_); michael@0: if(length($j) > 4) michael@0: { michael@0: $n = &jis0212tonum($j); michael@0: $map{$n} = $u; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: ## add eudc to $map here michael@0: michael@0: sub printtable() michael@0: { michael@0: for($i=0;$i<94;$i++) michael@0: { michael@0: printf ( "/* 0x%2XXX */\n", ( $i + 0x21)); michael@0: printf " "; michael@0: for($j=0;$j<94;$j++) michael@0: { michael@0: if("" == ($map{($i * 94 + $j)})) michael@0: { michael@0: print "0xFFFD," michael@0: } michael@0: else michael@0: { michael@0: print $map{($i * 94 + $j)} . ","; michael@0: } michael@0: if( 7 == (($j + 1) % 8)) michael@0: { michael@0: printf "/* 0x%2X%1X%1X*/\n", $i+0x21, 2+($j/16), (6==($j%16))?0:8; michael@0: } michael@0: } michael@0: printf " /* 0x%2X%1X%1X*/\n", $i+0x21, 2+($j/16),(6==($j%16))?0:8; michael@0: } michael@0: } michael@0: &readtable(); michael@0: &printtable(); michael@0: