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