Bug 468575 - Scrape some gunk off the config/ grout, r=ted
[wine-gecko.git] / intl / uconv / tools / cp932tojdx.pl
blob11247997c439cc692aa7b6d07224fa67d339f0b7
1 #!/user/local/bin/perl
2 sub sjistonum()
4 my($sjis) = (@_);
5 my($first,$second,$jnum);
6 $first = hex(substr($sjis,2,2));
7 $second = hex(substr($sjis,4,2));
8 if($first < 0xE0)
10 $jnum = ($first - 0x81) * ((0xfd - 0x80)+(0x7f - 0x40));
11 } else {
12 $jnum = ($first - 0xe0 + (0xa0-0x81)) * ((0xfd - 0x80)+(0x7f - 0x40));
14 if($second >= 0x80)
16 $jnum += $second - 0x80 + (0x7f-0x40);
18 else
20 $jnum += $second - 0x40;
22 return $jnum;
25 @map = {};
26 sub readtable()
28 open(CP932, "<CP932.TXT") || die "cannot open CP932.TXT";
29 while(<CP932>)
31 if(! /^#/) {
32 ($j, $u, $r) = split(/\t/,$_);
33 if(length($j) > 4)
35 $n = &sjistonum($j);
36 $map{$n} = $u;
42 ## add eudc to $map here
44 sub printtable()
46 for($i=0;$i<94;$i++)
48 printf ( "/* 0x%2XXX */\n", ( $i + 0x21));
49 printf " ";
50 for($j=0;$j<94;$j++)
52 if("" == ($map{($i * 94 + $j)}))
54 print "0xFFFD,"
56 else
58 print $map{($i * 94 + $j)} . ",";
60 if( 7 == (($j + 1) % 8))
62 printf "/* 0x%2X%1X%1X*/\n", $i+0x21, 2+($j/16), (6==($j%16))?0:8;
65 printf " /* 0x%2X%1X%1X*/\n", $i+0x21, 2+($j/16),(6==($j%16))?0:8;
68 &readtable();
69 &printtable();