1 # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
2 # National Institute of Advanced Industrial Science and Technology (AIST)
3 # Registration Number H13PRO009
5 # This file is part of GNU Emacs.
7 # GNU Emacs is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # GNU Emacs is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
35 function decode_hex
(str
) {
38 for (i =
1; i
<= len
; i
++)
40 c =
substr (str
, i
, 1);
41 if (c
>=
"0" && c
<=
"9")
42 n = n
* 16 + (c
- "0");
44 n = n
* 16 + tohex
[c
];
49 function decode_big5
(big5
) {
52 # (0xFF - 0xA1 + 0x7F - 0x40) = 157
53 # (0xA1 - (0x7F - 0x40)) = 98
54 # (0xC9 - 0xA1) * (0xFF - 0xA1 + 0x7F - 0x40) = 6280
56 idx =
(b0
- 161) * 157 + (b1
- 64);
58 idx =
(b0
- 161) * 157 + (b1
- 98);
61 b0 = int
(idx
/ 94) + 33;
63 return (b0
* 256 + b1
)
67 big5 = decode_hex
($
1);
68 code = decode_big5
(big5
);
69 printf "0x%04X %s\n", code
, $
2;