annotate admin/charsets/big5.awk @ 89917:1763eef5ad02

(encode_coding_utf_8): Fix handling of raw-byte char. (consume_chars): Fix handling of 8-bit bytes in unibyte source.
author Kenichi Handa <handa@m17n.org>
date Tue, 20 Apr 2004 02:46:38 +0000
parents e0e4e6a0599f
children ebb1b38229bc
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 decode_big5(big5) {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31 b0 = int(big5 / 256);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 b1 = big5 % 256;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 # (0xFF - 0xA1 + 0x7F - 0x40) = 157
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 # (0xA1 - (0x7F - 0x40)) = 98
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 # (0xC9 - 0xA1) * (0xFF - 0xA1 + 0x7F - 0x40) = 6280
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 if (b1 < 127)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 idx = (b0 - 161) * 157 + (b1 - 64);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
38 else
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 idx = (b0 - 161) * 157 + (b1 - 98);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 if (b0 >= 201)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 idx -= 6280;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42 b0 = int(idx / 94) + 33;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43 b1 = (idx % 94) + 33;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 return (b0 * 256 + b1)
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47 {
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 big5 = decode_hex($1);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 code = decode_big5(big5);
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50 printf "0x%04X %s\n", code, $2;
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 }
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52
375f2633d815 New directory
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53
89916
e0e4e6a0599f Changes from arch/CVS synchronization
Miles Bader <miles@gnu.org>
parents: 88123
diff changeset
54 # arch-tag: 36f08d21-0d24-4b67-852d-a9a51299586d