|
7 | 7 | # Generate UTF-8 <--> EUC_JIS_2004 code conversion tables from
|
8 | 8 | # "euc-jis-2004-std.txt" (http://x0213.org)
|
9 | 9 |
|
10 |
| -require"convutils.pm"; |
| 10 | +use strict; |
| 11 | +require convutils; |
11 | 12 |
|
12 | 13 | # first generate UTF-8 --> EUC_JIS_2004 table
|
13 | 14 |
|
14 |
| -$in_file ="euc-jis-2004-std.txt"; |
| 15 | +my$in_file ="euc-jis-2004-std.txt"; |
15 | 16 |
|
16 |
| -open(FILE,$in_file) ||die("cannot open$in_file"); |
| 17 | +open(my$in,'<',$in_file) ||die("cannot open$in_file"); |
17 | 18 |
|
18 | 19 | my@all;
|
19 | 20 |
|
20 |
| -while ($line = <FILE>) |
| 21 | +while (my$line = <$in>) |
21 | 22 | {
|
22 | 23 | if ($line =~/^0x(.*)[\t]*U\+(.*)\+(.*)[\t]*#(.*)$/)
|
23 | 24 | {
|
24 |
| -$c =$1; |
25 |
| -$u1 =$2; |
26 |
| -$u2 =$3; |
27 |
| -$rest ="U+" .$u1 ."+" .$u2 .$4; |
28 |
| -$code =hex($c); |
29 |
| -$ucs1 =hex($u1); |
30 |
| -$ucs2 =hex($u2); |
| 25 | +# combined characters |
| 26 | +my ($c,$u1,$u2) = ($1,$2,$3); |
| 27 | +my$rest ="U+" .$u1 ."+" .$u2 .$4; |
| 28 | +my$code =hex($c); |
| 29 | +my$ucs1 =hex($u1); |
| 30 | +my$ucs2 =hex($u2); |
31 | 31 |
|
32 | 32 | push@all, {direction=>'both',
|
33 | 33 | ucs=>$ucs1,
|
|
38 | 38 | }
|
39 | 39 | elsif ($line =~/^0x(.*)[\t]*U\+(.*)[\t]*#(.*)$/)
|
40 | 40 | {
|
41 |
| -$c =$1; |
42 |
| -$u =$2; |
43 |
| -$rest ="U+" .$u .$3; |
44 |
| -} |
45 |
| -else |
46 |
| -{ |
47 |
| -next; |
48 |
| -} |
49 |
| - |
50 |
| -$ucs =hex($u); |
51 |
| -$code =hex($c); |
| 41 | +# non-combined characters |
| 42 | +my ($c,$u,$rest) = ($1,$2,"U+" .$2 .$3); |
| 43 | +my$ucs =hex($u); |
| 44 | +my$code =hex($c); |
52 | 45 |
|
53 |
| -nextif ($code < 0x80 &&$ucs < 0x80); |
| 46 | +nextif ($code < 0x80 &&$ucs < 0x80); |
54 | 47 |
|
55 |
| -push@all, {direction=>'both',ucs=>$ucs,code=>$code,comment=>$rest }; |
| 48 | +push@all, {direction=>'both',ucs=>$ucs,code=>$code,comment=>$rest }; |
| 49 | +} |
56 | 50 | }
|
57 |
| -close(FILE); |
| 51 | +close($in); |
58 | 52 |
|
59 | 53 | print_tables("EUC_JIS_2004", \@all, 1);
|