Sync to HEAD
[bpt/emacs.git] / lisp / language / japanese.el
CommitLineData
0a10297a 1;;; japanese.el --- support for Japanese -*- coding: iso-2022-7bit; no-byte-compile: t -*-
4ed46869 2
4ed46869 3;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
8f924df7
KH
4;; Licensed to the Free Software Foundation.
5;; Copyright (C) 2003
6;; National Institute of Advanced Industrial Science and Technology (AIST)
7;; Registration Number H13PRO009
4ed46869
KH
8
9;; Keywords: multilingual, Japanese
10
11;; This file is part of GNU Emacs.
12
13;; GNU Emacs is free software; you can redistribute it and/or modify
14;; it under the terms of the GNU General Public License as published by
15;; the Free Software Foundation; either version 2, or (at your option)
16;; any later version.
17
18;; GNU Emacs is distributed in the hope that it will be useful,
19;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;; GNU General Public License for more details.
22
23;; You should have received a copy of the GNU General Public License
369314dc
KH
24;; along with GNU Emacs; see the file COPYING. If not, write to the
25;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26;; Boston, MA 02111-1307, USA.
4ed46869
KH
27
28;;; Commentary:
29
30;; For Japanese, character sets JISX0201, JISX0208, JISX0212 are
31;; supported.
32
33;;; Code:
34
3edfae2a
KH
35;;; Load translation tables for CP932.
36(load "international/cp51932")
37(load "international/eucjp-ms")
38
e1915ab3
KH
39(define-coding-system 'iso-2022-jp
40 "ISO 2022 based 7bit encoding for Japanese (MIME:ISO-2022-JP)."
41 :coding-type 'iso-2022
42 :mnemonic ?J
43 :designation [(ascii japanese-jisx0208-1978 japanese-jisx0208
18ac5bcc 44 latin-jisx0201)
e1915ab3
KH
45 nil nil nil]
46 :flags '(short ascii-at-eol ascii-at-cntl 7-bit designation)
18ac5bcc 47 :charset-list '(ascii japanese-jisx0208
56880b70 48 japanese-jisx0208-1978 latin-jisx0201)
d21363d3 49 :mime-charset 'iso-2022-jp)
25192984
KH
50
51(define-coding-system-alias 'junet 'iso-2022-jp)
dd53c981 52
e1915ab3
KH
53(define-coding-system 'iso-2022-jp-2
54 "ISO 2022 based 7bit encoding for CJK, Latin-1, Greek (MIME:ISO-2022-JP-2)."
55 :coding-type 'iso-2022
56 :mnemonic ?J
57 :designation [(ascii japanese-jisx0208-1978 japanese-jisx0208
58 latin-jisx0201 japanese-jisx0212
59 chinese-gb2312 korean-ksc5601)
60 nil
61 (nil latin-iso8859-1 greek-iso8859-7)
62 nil]
63 :flags '(short ascii-at-eol ascii-at-cntl 7-bit designation single-shift
64 init-at-bol)
56880b70
KH
65 :charset-list '(ascii japanese-jisx0208 japanese-jisx0212
66 latin-jisx0201 japanese-jisx0208-1978
e1915ab3
KH
67 chinese-gb2312 korean-ksc5601
68 latin-iso8859-1 greek-iso8859-7)
d21363d3 69 :mime-charset 'iso-2022-jp-2)
e1915ab3 70
021a9c9e 71(let ((map ; JIS vs CP932
3edfae2a 72 '((#x301C . #xFF5E) ; WAVE DASH FULLWIDTH TILDE
f525e544 73 (#x2014 . #x2015) ; EM DASH HORIZONTAL BAR
3edfae2a
KH
74 (#x2016 . #x2225) ; DOUBLE VERTICAL LINE PARALLEL TO
75 (#x2212 . #xFF0D) ; MINUS SIGN FULLWIDTH HYPHEN-MINUS
76 (#x00A2 . #xFFE0) ; CENT SIGN FULLWIDTH CENT SIGN
77 (#x00A3 . #xFFE1) ; POUND SIGN FULLWIDTH POUND SIGN
78 (#x00AC . #xFFE2) ; NOT SIGN FULLWIDTH NOT SIGN
021a9c9e 79 (#x00A6 . #xFFE4) ; BROKEN LINE FULLWIDTH BROKEN LINE
3edfae2a 80 )))
18ac5bcc 81 (define-translation-table 'japanese-ucs-jis-to-cp932-map map)
3edfae2a
KH
82 (mapc #'(lambda (x) (let ((tmp (car x)))
83 (setcar x (cdr x)) (setcdr x tmp)))
84 map)
18ac5bcc 85 (define-translation-table 'japanese-ucs-cp932-to-jis-map map))
3edfae2a
KH
86
87;; U+2014 (EM DASH) vs U+2015 (HORIZONTAL BAR)
f525e544
KH
88(define-translation-table 'japanese-ucs-glibc-to-jis-map '((#x2015 . #x2014)))
89(define-translation-table 'japanese-ucs-jis-to-glibc-map '((#x2014 . #x2015)))
3edfae2a 90
e1915ab3
KH
91(define-coding-system 'japanese-shift-jis
92 "Shift-JIS 8-bit encoding for Japanese (MIME:SHIFT_JIS)"
93 :coding-type 'shift-jis
94 :mnemonic ?S
95 :charset-list '(ascii katakana-jisx0201 japanese-jisx0208)
d21363d3 96 :mime-charset 'shift_jis)
4ed46869 97
71eabd24
RS
98(define-coding-system-alias 'shift_jis 'japanese-shift-jis)
99(define-coding-system-alias 'sjis 'japanese-shift-jis)
4ed46869 100
1cd8a175
KH
101(define-coding-system 'japanese-cp932
102 "CP932 (Microsoft shift-jis)"
103 :coding-type 'charset
104 :mnemonic ?S
105 :charset-list '(ascii katakana-sjis cp932-2-byte))
106
107(define-coding-system-alias 'cp932 'japanese-cp932)
108
e1915ab3
KH
109(define-coding-system 'japanese-iso-7bit-1978-irv
110 "ISO 2022 based 7-bit encoding for Japanese JISX0208-1978 and JISX0201-Roman."
111 :coding-type 'iso-2022
112 :mnemonic ?j
113 :designation [(latin-jisx0201 japanese-jisx0208-1978 japanese-jisx0208
114 japanese-jisx0212 katakana-jisx0201)
115 nil nil nil]
0783a1ec
KH
116 :flags '(short ascii-at-eol ascii-at-cntl 7-bit designation
117 use-roman use-oldjis)
118 :charset-list '(ascii latin-jisx0201 japanese-jisx0208-1978 japanese-jisx0208
119 japanese-jisx0212))
4ed46869 120
71eabd24
RS
121(define-coding-system-alias 'iso-2022-jp-1978-irv 'japanese-iso-7bit-1978-irv)
122(define-coding-system-alias 'old-jis 'japanese-iso-7bit-1978-irv)
dd53c981 123
e1915ab3
KH
124(define-coding-system 'japanese-iso-8bit
125 "ISO 2022 based EUC encoding for Japanese (MIME:EUC-JP)."
126 :coding-type 'iso-2022
127 :mnemonic ?E
128 :designation [ascii japanese-jisx0208 katakana-jisx0201 japanese-jisx0212]
129 :flags '(short ascii-at-eol ascii-at-cntl single-shift)
130 :charset-list '(ascii latin-jisx0201 japanese-jisx0208
49015dcb
KH
131 katakana-jisx0201 japanese-jisx0212
132 japanese-jisx0208-1978)
d21363d3 133 :mime-charset 'euc-jp)
4ed46869 134
71eabd24
RS
135(define-coding-system-alias 'euc-japan-1990 'japanese-iso-8bit)
136(define-coding-system-alias 'euc-japan 'japanese-iso-8bit)
137(define-coding-system-alias 'euc-jp 'japanese-iso-8bit)
4ed46869 138
3edfae2a
KH
139(define-coding-system 'eucjp-ms
140 "eucJP-ms (like EUC-JP but with CP932 extension).
141eucJP-ms is defined in <http://www.opengroup.or.jp/jvc/cde/appendix.html>."
142 :coding-type 'iso-2022
143 :mnemonic ?E
144 :designation [ascii japanese-jisx0208 katakana-jisx0201 japanese-jisx0212]
145 :flags '(short ascii-at-eol ascii-at-cntl single-shift)
146 :charset-list '(ascii latin-jisx0201 japanese-jisx0208
147 katakana-jisx0201 japanese-jisx0212)
148 :decode-translation-table 'eucjp-ms-decode
149 :encode-translation-table 'eucjp-ms-encode)
150
18ac5bcc
KH
151(define-coding-system 'iso-2022-jp-2004
152 "ISO 2022 based 7bit encoding for JIS X 0213:2004 (MIME:ISO-2022-JP-2004)."
153 :coding-type 'iso-2022
154 :mnemonic ?J
155 :designation [(ascii japanese-jisx0208 japanese-jisx0213.2004-1
156 japanese-jisx0213-1 japanese-jisx0213-2)
157 nil nil nil]
158 :flags '(short ascii-at-eol ascii-at-cntl 7-bit designation)
159 ;; init-at-bol)
160 :charset-list '(ascii japanese-jisx0208 japanese-jisx0213.2004-1
161 japanese-jisx0213-1 japanese-jisx0213-2)
162 :mime-charset 'iso-2022-jp-2004)
163
164(define-coding-system-alias 'iso-2022-jp-3 'iso-2022-jp-2004)
165
166(define-coding-system 'euc-jis-2004
167 "ISO 2022 based EUC encoding for JIS X 0213 (MIME:EUC-JIS-2004)."
168 :coding-type 'iso-2022
169 :mnemonic ?E
170 :designation [ascii japanese-jisx0213.2004-1 katakana-jisx0201
171 japanese-jisx0213-2]
172 :flags '(short ascii-at-eol ascii-at-cntl single-shift)
173 :charset-list '(ascii latin-jisx0201 japanese-jisx0213.2004-1
174 japanese-jisx0213-1 katakana-jisx0201
175 japanese-jisx0213-2)
176 :mime-charset 'euc-jis-2004)
177
178(define-coding-system-alias 'euc-jisx0213 'euc-jis-2004)
179
180(define-coding-system 'japanese-shift-jis-2004
181 "Shift_JIS 8-bit encodinf for Japanese (MIME:SHIFT_JIS-2004)"
182 :coding-type 'shift-jis
183 :mnemonic ?S
184 :charset-list '(ascii katakana-jisx0201
185 japanese-jisx0213.2004-1 japanese-jisx0213-2))
186
187(define-coding-system-alias 'shift_jis-2004 'japanese-shift-jis-2004)
188
4ed46869 189(set-language-info-alist
a564ccf9 190 "Japanese" '((setup-function . setup-japanese-environment-internal)
c089af63 191 (tutorial . "TUTORIAL.ja")
a79a3c79 192 (charset japanese-jisx0208 japanese-jisx0208-1978
d6f08fd9 193 japanese-jisx0212 latin-jisx0201 katakana-jisx0201
18ac5bcc
KH
194 japanese-jisx0213.2004-1 japanese-jisx0213-1
195 japanese-jisx0213-2)
a79a3c79 196 (coding-system iso-2022-jp japanese-iso-8bit
18ac5bcc
KH
197 japanese-shift-jis japanese-iso-7bit-1978-irv
198 iso-2022-jp-2004 japanese-shift-jis-2004
199 euc-jis-2004)
a79a3c79 200 (coding-priority iso-2022-jp japanese-iso-8bit
18ac5bcc
KH
201 japanese-shift-jis
202 iso-2022-jp-2004 euc-jis-2004
203 japanese-shift-jis-2004
204 iso-2022-jp-2)
a564ccf9
KH
205 (input-method . "japanese")
206 (features japan-util)
a79a3c79 207 (sample-text . "Japanese (\e$BF|K\8l\e(B) \e$B$3$s$K$A$O\e(B, \e(I:]FAJ\e(B")
78eee0ed 208 (documentation . t)))
4ed46869 209
0c4fbd05
KH
210(let ((map
211 ;; JISX0213-1 vs Unicode
212 '((#x2477 . [#x304B #x309A])
213 (#x2478 . [#x304D #x309A])
214 (#x2479 . [#x304F #x309A])
215 (#x247a . [#x3051 #x309A])
216 (#x247b . [#x3053 #x309A])
217 (#x2577 . [#x30AB #x309A])
218 (#x2578 . [#x30AD #x309A])
219 (#x2579 . [#x30AF #x309A])
220 (#x257a . [#x30B1 #x309A])
221 (#x257b . [#x30B3 #x309A])
222 (#x257c . [#x30BB #x309A])
223 (#x257d . [#x30C4 #x309A])
224 (#x257e . [#x30C8 #x309A])
225 (#x2678 . [#x31F7 #x309A])
226 (#x2b44 . [#x00E6 #x0300])
227 (#x2b48 . [#x0254 #x0300])
228 (#x2b49 . [#x0254 #x0301])
229 (#x2b4a . [#x028C #x0300])
230 (#x2b4b . [#x028C #x0301])
231 (#x2b4c . [#x0259 #x0300])
232 (#x2b4d . [#x0259 #x0301])
233 (#x2b4e . [#x025A #x0300])
234 (#x2b4f . [#x025A #x0301])
235 (#x2b65 . [#x02E9 #x02E5])
236 (#x2b66 . [#x02E5 #x02E9])))
237 table)
238 (dolist (elt map)
239 (setcar elt (decode-char 'japanese-jisx0213-1 (car elt))))
240 (setq table (make-translation-table-from-alist map))
241 (define-translation-table 'jisx0213-to-unicode table)
242 (define-translation-table 'unicode-to-jisx0213
243 (char-table-extra-slot table 0)))
244
41da80b1
DL
245(provide 'japanese)
246
6b61353c 247;;; arch-tag: 450f5537-9d53-4d5e-b731-4cf116d8cbc9
4ed46869 248;;; japanese.el ends here