annotate admin/charsets/gb180304.awk @ 90924:62c0548e9e67

*** empty log message ***
author Jason Rumney <jasonr@gnu.org>
date Mon, 11 Jun 2007 22:08:57 +0000
parents e0e4e6a0599f
children c8aabc9d9db2
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 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 function decode_hex(str) {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 n = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18 len = length(str);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19 for (i = 1; i <= len; i++)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21 c = substr (str, i, 1);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 if (c >= "0" && c <= "9")
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23 n = n * 16 + (c - "0");
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24 else
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 n = n * 16 + tohex[c];
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27 return n;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
30 function gb_to_index(gb) {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 b0 = int(gb / 256);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 b1 = gb % 256;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 idx = (((b0 - 129)) * 191 + b1 - 64);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 # if (b1 >= 127)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 # idx--;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 return idx
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 function index_to_gb(idx) {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 b3 = (idx % 10) + 48;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 idx = int(idx / 10);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42 b2 = (idx % 126) + 129;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43 idx = int(idx / 126);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 b1 = (idx % 10) + 48;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 b0 = int(idx / 10) + 129;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 return sprintf("%02X%02X%02X%02X", b0, b1, b2, b3);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 /^\#/ {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50 print;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 next;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54 /0x....-0x..../ {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
55 gb_from = gb_to_index(decode_hex(substr($1, 3, 4)));
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
56 gb_to = gb_to_index(decode_hex(substr($1, 10, 4)));
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
57 unicode = decode_hex(substr($2, 3, 4));
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
58 while (gb_from <= gb_to)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
59 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
60 table[unicode++] = 1;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
61 gb_from++;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63 next;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
65
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67 gb = decode_hex(substr($1, 3, 4));
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68 unicode = decode_hex(substr($2, 3, 4));
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 table[unicode] = 1;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
71
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 END {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73 from_gb = -1;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
74 to_gb = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75 from_i = 0;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76 table[65536] = 1;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77 for (i = 128; i <= 65536; i++)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79 if (table[i] == 0)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 if (i < 55296 || i >= 57344)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83 if (from_gb < 0)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85 from_gb = to_gb;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 from_i = i;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88 to_gb++;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91 else if (from_gb >= 0)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93 if (from_gb + 1 == to_gb)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 printf "0x%s\t\t0x%04X\n",
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 index_to_gb(from_gb), from_i;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 else
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 printf "0x%s-0x%s\t0x%04X\n",
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98 index_to_gb(from_gb), index_to_gb(to_gb - 1), from_i;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 from_gb = -1;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102 }
89916
e0e4e6a0599f Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 88123
diff changeset
103
e0e4e6a0599f Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 88123
diff changeset
104 # arch-tag: 8e5a22ae-610e-411f-ae17-d6e528b30d71