Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
[emacs.git] / admin / charsets / cp51932.awk
blob22b24af1ef5e71bd6ff0d6a93e71e186841953ff
1 # cp51932.awk -- Generate a translation table for CP51932.
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 <https://www.gnu.org/licenses/>.
21 # Commentary:
23 # Generate a translation table for CP51932 (EUC-JP of MicroSoft Version).
24 # It maps invalid JISX0208 code points used by CP51932 to Unicode.
25 # 4th field of the input has these meanings:
26 # 0: JISX0208 characters.
27 # 1: NEC special characters.
28 # 2: IBM extension characters.
29 # 3: NEC selection of IBM extension characters.
30 # Among them, 1 and 3 are the target characters. 2 should have
31 # already been mapped to 1 or 3.
33 BEGIN {
34 print ";;; cp51932.el -- translation table for CP51932 -*- lexical-binding:t -*-";
35 print ";;; Automatically generated from CP932-2BYTE.map";
36 print "(let ((map";
37 printf " '(;JISEXT<->UNICODE";
40 /# [13]/ {
41 printf "\n (#x%s . #x%s)", $5 ,substr($2, 3, 4);
44 END {
45 print ")))";
46 print " (setq map (mapcar (lambda (x)";
47 print " (cons (decode-char 'japanese-jisx0208 (car x))";
48 print " (cdr x)))";
49 print " map))";
50 print " (define-translation-table 'cp51932-decode map)";
51 print " (mapc (lambda (x)";
52 print " (let ((tmp (car x)))";
53 print " (setcar x (cdr x)) (setcdr x tmp)))";
54 print " map)";
55 print " (define-translation-table 'cp51932-encode map))";
56 print "";
57 print "(provide 'cp51932)";