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/>.
39 function decode_hex
(str
) {
42 for (i =
1; i
<= len
; i
++)
44 c =
substr (str
, i
, 1);
45 if (c
>=
"0" && c
<=
"9")
46 n = n
* 16 + (c
- "0");
48 n = n
* 16 + tohex
[c
];
53 function gb_to_index
(gb
) {
56 idx =
(((b0
- 129)) * 191 + b1
- 64);
62 function index_to_gb
(idx
) {
63 b0 = int
(idx
/ 191) + 129;
64 b1 =
(idx %
191) + 64;
67 return (b0
* 256 + b1
);
76 gb = gb_to_index
(decode_hex
(substr($
1, 3, 4)));
77 unicode = decode_hex
(substr($
2, 3));
78 if ((gb == to_gb
+ 1) && (unicode == to_unicode
+ 1))
83 else if (gb
> to_gb
) # ignore the case gb == to_gb that is a duplication
87 if (from_unicode
<=
65535)
88 printf "0x%04X 0x%04X\n", index_to_gb
(from_gb
), from_unicode
;
90 printf "0x%04X 0x%08X\n", index_to_gb
(from_gb
), from_unicode
;
92 else if (from_gb
< to_gb
)
94 if (from_unicode
<=
65535)
95 printf "0x%04X-0x%04X 0x%04X\n",
96 index_to_gb
(from_gb
), index_to_gb
(to_gb
), from_unicode
;
98 printf "0x%04X-0x%04X 0x%08X\n",
99 index_to_gb
(from_gb
), index_to_gb
(to_gb
), from_unicode
;
101 from_gb = to_gb = gb
;
102 from_unicode = to_unicode = unicode
;
107 if (from_gb
<= to_gb
)
108 printf "0x%04X-0x%04X 0x%04X\n",
109 index_to_gb
(from_gb
), index_to_gb
(to_gb
), from_unicode
;