]> code.delx.au - gnu-emacs/blob - lisp/language/japanese.el
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-25
[gnu-emacs] / lisp / language / japanese.el
1 ;;; japanese.el --- support for Japanese -*- coding: iso-2022-7bit; no-byte-compile: t -*-
2
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
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
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
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.
27
28 ;;; Commentary:
29
30 ;; For Japanese, character sets JISX0201, JISX0208, JISX0212 are
31 ;; supported.
32
33 ;;; Code:
34
35 ;;; Load translation tables for CP932.
36 (load "international/cp51932")
37 (load "international/eucjp-ms")
38
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
44 latin-jisx0201)
45 nil nil nil]
46 :flags '(short ascii-at-eol ascii-at-cntl 7-bit designation)
47 :charset-list '(ascii japanese-jisx0208
48 japanese-jisx0208-1978 latin-jisx0201)
49 :mime-charset 'iso-2022-jp)
50
51 (define-coding-system-alias 'junet 'iso-2022-jp)
52
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)
65 :charset-list '(ascii japanese-jisx0208 japanese-jisx0212
66 latin-jisx0201 japanese-jisx0208-1978
67 chinese-gb2312 korean-ksc5601
68 latin-iso8859-1 greek-iso8859-7)
69 :mime-charset 'iso-2022-jp-2)
70
71 (let ((map ; JIS vs CP932
72 '((#x301C . #xFF5E) ; WAVE DASH FULLWIDTH TILDE
73 (#x2014 . #x2015) ; EM DASH HORIZONTAL BAR
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
79 (#x00A6 . #xFFE4) ; BROKEN LINE FULLWIDTH BROKEN LINE
80 )))
81 (define-translation-table 'japanese-ucs-jis-to-cp932-map map)
82 (mapc #'(lambda (x) (let ((tmp (car x)))
83 (setcar x (cdr x)) (setcdr x tmp)))
84 map)
85 (define-translation-table 'japanese-ucs-cp932-to-jis-map map))
86
87 ;; U+2014 (EM DASH) vs U+2015 (HORIZONTAL BAR)
88 (define-translation-table 'japanese-ucs-glibc-to-jis-map '((#x2015 . #x2014)))
89 (define-translation-table 'japanese-ucs-jis-to-glibc-map '((#x2014 . #x2015)))
90
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)
96 :mime-charset 'shift_jis)
97
98 (define-coding-system-alias 'shift_jis 'japanese-shift-jis)
99 (define-coding-system-alias 'sjis 'japanese-shift-jis)
100 (define-coding-system-alias 'cp932 'japanese-shift-jis)
101
102 (define-coding-system 'japanese-cp932
103 "CP932 (Microsoft shift-jis)"
104 :coding-type 'charset
105 :mnemonic ?S
106 :charset-list '(ascii katakana-sjis cp932-2-byte))
107
108 (define-coding-system-alias 'cp932 'japanese-cp932)
109
110 (define-coding-system 'japanese-iso-7bit-1978-irv
111 "ISO 2022 based 7-bit encoding for Japanese JISX0208-1978 and JISX0201-Roman."
112 :coding-type 'iso-2022
113 :mnemonic ?j
114 :designation [(latin-jisx0201 japanese-jisx0208-1978 japanese-jisx0208
115 japanese-jisx0212 katakana-jisx0201)
116 nil nil nil]
117 :flags '(short ascii-at-eol ascii-at-cntl 7-bit designation
118 use-roman use-oldjis)
119 :charset-list '(ascii latin-jisx0201 japanese-jisx0208-1978 japanese-jisx0208
120 japanese-jisx0212))
121
122 (define-coding-system-alias 'iso-2022-jp-1978-irv 'japanese-iso-7bit-1978-irv)
123 (define-coding-system-alias 'old-jis 'japanese-iso-7bit-1978-irv)
124
125 (define-coding-system 'japanese-iso-8bit
126 "ISO 2022 based EUC encoding for Japanese (MIME:EUC-JP)."
127 :coding-type 'iso-2022
128 :mnemonic ?E
129 :designation [ascii japanese-jisx0208 katakana-jisx0201 japanese-jisx0212]
130 :flags '(short ascii-at-eol ascii-at-cntl single-shift)
131 :charset-list '(ascii latin-jisx0201 japanese-jisx0208
132 katakana-jisx0201 japanese-jisx0212
133 japanese-jisx0208-1978)
134 :mime-charset 'euc-jp)
135
136 (define-coding-system-alias 'euc-japan-1990 'japanese-iso-8bit)
137 (define-coding-system-alias 'euc-japan 'japanese-iso-8bit)
138 (define-coding-system-alias 'euc-jp 'japanese-iso-8bit)
139
140 (define-coding-system 'eucjp-ms
141 "eucJP-ms (like EUC-JP but with CP932 extension).
142 eucJP-ms is defined in <http://www.opengroup.or.jp/jvc/cde/appendix.html>."
143 :coding-type 'iso-2022
144 :mnemonic ?E
145 :designation [ascii japanese-jisx0208 katakana-jisx0201 japanese-jisx0212]
146 :flags '(short ascii-at-eol ascii-at-cntl single-shift)
147 :charset-list '(ascii latin-jisx0201 japanese-jisx0208
148 katakana-jisx0201 japanese-jisx0212)
149 :decode-translation-table 'eucjp-ms-decode
150 :encode-translation-table 'eucjp-ms-encode)
151
152 (define-coding-system 'iso-2022-jp-2004
153 "ISO 2022 based 7bit encoding for JIS X 0213:2004 (MIME:ISO-2022-JP-2004)."
154 :coding-type 'iso-2022
155 :mnemonic ?J
156 :designation [(ascii japanese-jisx0208 japanese-jisx0213.2004-1
157 japanese-jisx0213-1 japanese-jisx0213-2)
158 nil nil nil]
159 :flags '(short ascii-at-eol ascii-at-cntl 7-bit designation)
160 ;; init-at-bol)
161 :charset-list '(ascii japanese-jisx0208 japanese-jisx0213.2004-1
162 japanese-jisx0213-1 japanese-jisx0213-2)
163 :mime-charset 'iso-2022-jp-2004)
164
165 (define-coding-system-alias 'iso-2022-jp-3 'iso-2022-jp-2004)
166
167 (define-coding-system 'euc-jis-2004
168 "ISO 2022 based EUC encoding for JIS X 0213 (MIME:EUC-JIS-2004)."
169 :coding-type 'iso-2022
170 :mnemonic ?E
171 :designation [ascii japanese-jisx0213.2004-1 katakana-jisx0201
172 japanese-jisx0213-2]
173 :flags '(short ascii-at-eol ascii-at-cntl single-shift)
174 :charset-list '(ascii latin-jisx0201 japanese-jisx0213.2004-1
175 japanese-jisx0213-1 katakana-jisx0201
176 japanese-jisx0213-2)
177 :mime-charset 'euc-jis-2004)
178
179 (define-coding-system-alias 'euc-jisx0213 'euc-jis-2004)
180
181 (define-coding-system 'japanese-shift-jis-2004
182 "Shift_JIS 8-bit encodinf for Japanese (MIME:SHIFT_JIS-2004)"
183 :coding-type 'shift-jis
184 :mnemonic ?S
185 :charset-list '(ascii katakana-jisx0201
186 japanese-jisx0213.2004-1 japanese-jisx0213-2))
187
188 (define-coding-system-alias 'shift_jis-2004 'japanese-shift-jis-2004)
189
190 (set-language-info-alist
191 "Japanese" '((setup-function . setup-japanese-environment-internal)
192 (tutorial . "TUTORIAL.ja")
193 (charset japanese-jisx0208
194 japanese-jisx0212 latin-jisx0201 katakana-jisx0201
195 japanese-jisx0213.2004-1 japanese-jisx0213-1
196 japanese-jisx0213-2 japanese-jisx0208-1978)
197 (coding-system iso-2022-jp japanese-iso-8bit
198 japanese-shift-jis japanese-iso-7bit-1978-irv
199 iso-2022-jp-2004 japanese-shift-jis-2004
200 euc-jis-2004)
201 (coding-priority iso-2022-jp japanese-iso-8bit
202 japanese-shift-jis
203 iso-2022-jp-2004 euc-jis-2004
204 japanese-shift-jis-2004
205 iso-2022-jp-2)
206 (input-method . "japanese")
207 (features japan-util)
208 (sample-text . "Japanese (\e$BF|K\8l\e(B) \e$B$3$s$K$A$O\e(B, \e(I:]FAJ\e(B")
209 (documentation . t)))
210
211 (let ((map
212 ;; JISX0213-1 vs Unicode
213 '((#x2477 . [#x304B #x309A])
214 (#x2478 . [#x304D #x309A])
215 (#x2479 . [#x304F #x309A])
216 (#x247a . [#x3051 #x309A])
217 (#x247b . [#x3053 #x309A])
218 (#x2577 . [#x30AB #x309A])
219 (#x2578 . [#x30AD #x309A])
220 (#x2579 . [#x30AF #x309A])
221 (#x257a . [#x30B1 #x309A])
222 (#x257b . [#x30B3 #x309A])
223 (#x257c . [#x30BB #x309A])
224 (#x257d . [#x30C4 #x309A])
225 (#x257e . [#x30C8 #x309A])
226 (#x2678 . [#x31F7 #x309A])
227 (#x2b44 . [#x00E6 #x0300])
228 (#x2b48 . [#x0254 #x0300])
229 (#x2b49 . [#x0254 #x0301])
230 (#x2b4a . [#x028C #x0300])
231 (#x2b4b . [#x028C #x0301])
232 (#x2b4c . [#x0259 #x0300])
233 (#x2b4d . [#x0259 #x0301])
234 (#x2b4e . [#x025A #x0300])
235 (#x2b4f . [#x025A #x0301])
236 (#x2b65 . [#x02E9 #x02E5])
237 (#x2b66 . [#x02E5 #x02E9])))
238 table)
239 (dolist (elt map)
240 (setcar elt (decode-char 'japanese-jisx0213-1 (car elt))))
241 (setq table (make-translation-table-from-alist map))
242 (define-translation-table 'jisx0213-to-unicode table)
243 (define-translation-table 'unicode-to-jisx0213
244 (char-table-extra-slot table 0)))
245
246 (provide 'japanese)
247
248 ;;; arch-tag: 450f5537-9d53-4d5e-b731-4cf116d8cbc9
249 ;;; japanese.el ends here