~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/intl/uconv/tools/cp932tojdx.pl

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/user/local/bin/perl
 
2
sub sjistonum()
 
3
{
 
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)
 
9
   {
 
10
      $jnum = ($first - 0x81) * ((0xfd - 0x80)+(0x7f - 0x40));
 
11
   } else {
 
12
      $jnum = ($first - 0xe0 + (0xa0-0x81)) * ((0xfd - 0x80)+(0x7f - 0x40));
 
13
   }
 
14
   if($second >= 0x80)
 
15
   {
 
16
       $jnum += $second - 0x80 + (0x7f-0x40);
 
17
   }
 
18
   else
 
19
   {
 
20
       $jnum += $second - 0x40;
 
21
   }
 
22
   return $jnum;
 
23
}
 
24
 
 
25
@map = {};
 
26
sub readtable()
 
27
{
 
28
open(CP932, "<CP932.TXT") || die "cannot open CP932.TXT";
 
29
while(<CP932>)
 
30
{
 
31
   if(! /^#/) {
 
32
        ($j, $u, $r) = split(/\t/,$_);
 
33
        if(length($j) > 4)
 
34
        {
 
35
        $n = &sjistonum($j);
 
36
        $map{$n} = $u;
 
37
        }
 
38
   } 
 
39
}
 
40
}
 
41
 
 
42
## add eudc to  $map here
 
43
 
 
44
sub printtable()
 
45
{
 
46
for($i=0;$i<94;$i++)
 
47
{
 
48
     printf ( "/* 0x%2XXX */\n", ( $i + 0x21));
 
49
     printf "       ";
 
50
     for($j=0;$j<94;$j++)
 
51
     {
 
52
         if("" == ($map{($i * 94 + $j)}))
 
53
         {
 
54
            print "0xFFFD,"
 
55
         } 
 
56
         else 
 
57
         {   
 
58
            print $map{($i * 94 + $j)} . ",";
 
59
         }
 
60
         if( 7 == (($j + 1) % 8))
 
61
         {
 
62
            printf "/* 0x%2X%1X%1X*/\n", $i+0x21, 2+($j/16), (6==($j%16))?0:8;
 
63
         }
 
64
     }
 
65
     printf "       /* 0x%2X%1X%1X*/\n", $i+0x21, 2+($j/16),(6==($j%16))?0:8;
 
66
}
 
67
}
 
68
&readtable();
 
69
&printtable();
 
70