1 # eucjp-ms.awk -- Generate a translation table for eucJP-ms.
2 # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
3 # National Institute of Advanced Industrial Science and Technology (AIST)
4 # Registration Number H13PRO009
6 # This file is part of GNU Emacs.
8 # GNU Emacs is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # GNU Emacs is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 # eucJP-ms is one of eucJP-open encoding defined at this page:
24 # http://home.m05.itscom.net/numa/cde/ucs-conv/appendix.html
25 # This program reads the mapping file EUC-JP-MS (of glibc) and
26 # generates the Elisp file eucjp-ms.el that defines two translation
27 # tables `eucjp-ms-decode' and `eucjp-ms-encode'.
32 # STATE: 0/ignore, 1/JISX0208, 2/JISX0208 target range
33 # 3/JISX0212 4/JISX0212 target range
36 JISX0208_FROM1 =
"/xad/xa1";
37 JISX0208_TO1 =
"/xad/xfc";
38 JISX0208_FROM2 =
"/xf5/xa1";
39 JISX0212_FROM =
"/x8f/xf3/xf3";
41 print ";;; eucjp-ms.el -- translation table for eucJP-ms. -*- no-byte-compile: t -*-";
42 print ";;; Automatically generated from /usr/share/i18n/charmaps/EUC-JP-MS.gz";
44 print " '(;JISEXT<->UNICODE";
47 function write_entry
(unicode
) {
49 if ($
2 == JISX0208_FROM1
|| $
2 == JISX0208_FROM2
)
51 } else if (state ==
3) {
52 if ($
2 == JISX0212_FROM
)
58 printf "\n (#x%s . #x%s)", jis
, unicode
;
59 if ($
2 == JISX0208_TO1
)
61 } else if (state ==
4) {
62 jis =
substr($
2, 5, 8);
64 printf "\n (#x%s #x%s)", jis
, unicode
;
84 /^
<U
[0-9A
-Z
][0-9A
-Z
][0-9A
-Z
][0-9A
-Z
]>/ {
86 write_entry
(substr($
1, 3, 4));
89 /^%IRREVERSIBLE%
<U
[0-9A
-Z
][0-9A
-Z
][0-9A
-Z
][0-9A
-Z
]>/ {
91 write_entry
(substr($
1, 17, 4));
96 print " (mapc #'(lambda (x)";
97 print " (let ((code (logand (car x) #x7F7F)))";
98 print " (if (integerp (cdr x))";
99 print " (setcar x (decode-char 'japanese-jisx0208 code))";
100 print " (setcar x (decode-char 'japanese-jisx0212 code))";
101 print " (setcdr x (cadr x)))))";
103 print " (define-translation-table 'eucjp-ms-decode map)";
104 print " (mapc #'(lambda (x)";
105 print " (let ((tmp (car x)))";
106 print " (setcar x (cdr x)) (setcdr x tmp)))";
108 print " (define-translation-table 'eucjp-ms-encode map))";