annotate admin/charsets/gb180302.awk @ 90173:2ad2f1b71a5b

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Wed, 11 May 2005 12:27:57 +0000
parents e0e4e6a0599f
children 350e1f95b7d0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88123
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1 BEGIN {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2 tohex["A"] = 10;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3 tohex["B"] = 11;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 tohex["C"] = 12;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
5 tohex["D"] = 13;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6 tohex["E"] = 14;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7 tohex["F"] = 15;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8 tohex["a"] = 10;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9 tohex["b"] = 11;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
10 tohex["c"] = 12;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
11 tohex["d"] = 13;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
12 tohex["e"] = 14;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13 tohex["f"] = 15;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
14 from_gb = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15 to_gb = -1;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 to_unicode = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 from_unicode = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20 function decode_hex(str) {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21 n = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 len = length(str);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23 for (i = 1; i <= len; i++)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 c = substr (str, i, 1);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26 if (c >= "0" && c <= "9")
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 n = n * 16 + (c - "0");
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 else
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 n = n * 16 + tohex[c];
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 return n;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 function gb_to_index(gb) {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 b0 = int(gb / 256);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 b1 = gb % 256;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 idx = (((b0 - 129)) * 191 + b1 - 64);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38 # if (b1 >= 128)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 # idx--;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 return idx
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43 function index_to_gb(idx) {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 b0 = int(idx / 191) + 129;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 b1 = (idx % 191) + 64;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 # if (b1 >= 127)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47 # b1++;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 return (b0 * 256 + b1);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 /^\#/ {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52 print;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53 next;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
55
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
56 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
57 gb = gb_to_index(decode_hex(substr($1, 3, 4)));
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
58 unicode = decode_hex(substr($2, 3, 4));
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
59 if ((gb == to_gb + 1) && (unicode == to_unicode + 1))
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
61 to_gb++;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62 to_unicode++;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64 else
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
65 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66 if (from_gb == to_gb)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67 printf "0x%04X 0x%04X\n", index_to_gb(from_gb), from_unicode;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68 else if (from_gb < to_gb)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 printf "0x%04X-0x%04X 0x%04X\n",
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70 index_to_gb(from_gb), index_to_gb(to_gb), from_unicode;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
71 from_gb = to_gb = gb;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 from_unicode = to_unicode = unicode;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
74 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76 END {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77 if (from_gb <= to_gb)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78 printf "0x%04X-0x%04X 0x%04X\n",
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79 index_to_gb(from_gb), index_to_gb(to_gb), from_unicode;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 }
89916
e0e4e6a0599f Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 88123
diff changeset
81
e0e4e6a0599f Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 88123
diff changeset
82 # arch-tag: d7dbad89-a512-41a4-8ee0-ba1a4505b8c1