88674
|
1 BEGIN {
|
|
2 tohex["A"] = 10;
|
|
3 tohex["B"] = 11;
|
|
4 tohex["C"] = 12;
|
|
5 tohex["D"] = 13;
|
|
6 tohex["E"] = 14;
|
|
7 tohex["F"] = 15;
|
|
8 tohex["a"] = 10;
|
|
9 tohex["b"] = 11;
|
|
10 tohex["c"] = 12;
|
|
11 tohex["d"] = 13;
|
|
12 tohex["e"] = 14;
|
|
13 tohex["f"] = 15;
|
|
14 }
|
|
15
|
|
16 function decode_hex(str) {
|
|
17 n = 0;
|
|
18 len = length(str);
|
|
19 for (i = 1; i <= len; i++)
|
|
20 {
|
|
21 c = substr (str, i, 1);
|
|
22 if (c >= "0" && c <= "9")
|
|
23 n = n * 16 + (c - "0");
|
|
24 else
|
|
25 n = n * 16 + tohex[c];
|
|
26 }
|
|
27 return n;
|
|
28 }
|
|
29
|
|
30 function gb_to_index(gb) {
|
|
31 b0 = int(gb / 256);
|
|
32 b1 = gb % 256;
|
|
33 idx = (((b0 - 129)) * 190 + b1 - 64);
|
|
34 if (b1 >= 128)
|
|
35 idx--;
|
|
36 return idx
|
|
37 }
|
|
38
|
|
39 function index_to_gb(idx) {
|
|
40 b0 = int(idx / 190) + 129;
|
|
41 b1 = (idx % 190) + 64;
|
|
42 if (b1 >= 127)
|
|
43 b1++;
|
|
44 return (b0 * 256 + b1);
|
|
45 }
|
|
46 function decode_gb(str) {
|
|
47 b0 = decode_hex(substr(str, 3, 2));
|
|
48 b1 = decode_hex(substr(str, 7, 2));
|
|
49 return (b0 * 256 + b1)
|
|
50 }
|
|
51
|
|
52 /^<U[0-9A-F][0-9A-F][0-9A-F][0-9A-F]>/ {
|
|
53 if ($2 ~ /^\\x[0-9A-F][0-9A-F]\\x[0-9A-F][0-9A-F]$/)
|
|
54 {
|
|
55 unicode = decode_hex(substr($1, 3, 4));
|
|
56 gb = decode_gb($2);
|
|
57 idx = gb_to_index(gb);
|
|
58 gb_table[idx] = unicode;
|
|
59 }
|
|
60 }
|
|
61
|
|
62 END {
|
|
63 last_idx = gb_to_index(decode_hex("FEFE"));
|
|
64 from_idx = 0;
|
|
65 from_unicode = gb_table[0];
|
|
66 for (i = 1; i <= last_idx; i++)
|
|
67 {
|
|
68 gb = index_to_gb(i);
|
|
69 unicode = gb_table[i];
|
|
70 if (i - from_idx != unicode - from_unicode)
|
|
71 {
|
|
72 if (i - 1 == from_idx)
|
|
73 printf ("0x%04X 0x%04X\n",
|
|
74 index_to_gb(from_idx), from_unicode);
|
|
75 else
|
|
76 printf ("0x%04X-0x%04X 0x%04X\n",
|
|
77 index_to_gb(from_idx), index_to_gb(i - 1), from_unicode);
|
|
78 from_idx = i;
|
|
79 from_unicode=unicode;
|
|
80 }
|
|
81 }
|
|
82 if (i - from_idx != unicode - from_unicode)
|
|
83 printf ("0x%04X-0x%04X 0x%04X\n",
|
|
84 index_to_gb(from_idx), index_to_gb(i - 1), from_unicode);
|
|
85 }
|