Mercurial > emacs
annotate admin/charsets/gb180302.awk @ 90395:65fc70a77429
(system_eol_type): Fix synching with HEAD.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 15 May 2006 02:49:33 +0000 |
parents | e0e4e6a0599f |
children | 350e1f95b7d0 |
rev | line source |
---|---|
88123 | 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 from_gb = 0; | |
15 to_gb = -1; | |
16 to_unicode = 0; | |
17 from_unicode = 0; | |
18 } | |
19 | |
20 function decode_hex(str) { | |
21 n = 0; | |
22 len = length(str); | |
23 for (i = 1; i <= len; i++) | |
24 { | |
25 c = substr (str, i, 1); | |
26 if (c >= "0" && c <= "9") | |
27 n = n * 16 + (c - "0"); | |
28 else | |
29 n = n * 16 + tohex[c]; | |
30 } | |
31 return n; | |
32 } | |
33 | |
34 function gb_to_index(gb) { | |
35 b0 = int(gb / 256); | |
36 b1 = gb % 256; | |
37 idx = (((b0 - 129)) * 191 + b1 - 64); | |
38 # if (b1 >= 128) | |
39 # idx--; | |
40 return idx | |
41 } | |
42 | |
43 function index_to_gb(idx) { | |
44 b0 = int(idx / 191) + 129; | |
45 b1 = (idx % 191) + 64; | |
46 # if (b1 >= 127) | |
47 # b1++; | |
48 return (b0 * 256 + b1); | |
49 } | |
50 | |
51 /^\#/ { | |
52 print; | |
53 next; | |
54 } | |
55 | |
56 { | |
57 gb = gb_to_index(decode_hex(substr($1, 3, 4))); | |
58 unicode = decode_hex(substr($2, 3, 4)); | |
59 if ((gb == to_gb + 1) && (unicode == to_unicode + 1)) | |
60 { | |
61 to_gb++; | |
62 to_unicode++; | |
63 } | |
64 else | |
65 { | |
66 if (from_gb == to_gb) | |
67 printf "0x%04X 0x%04X\n", index_to_gb(from_gb), from_unicode; | |
68 else if (from_gb < to_gb) | |
69 printf "0x%04X-0x%04X 0x%04X\n", | |
70 index_to_gb(from_gb), index_to_gb(to_gb), from_unicode; | |
71 from_gb = to_gb = gb; | |
72 from_unicode = to_unicode = unicode; | |
73 } | |
74 } | |
75 | |
76 END { | |
77 if (from_gb <= to_gb) | |
78 printf "0x%04X-0x%04X 0x%04X\n", | |
79 index_to_gb(from_gb), index_to_gb(to_gb), from_unicode; | |
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 |