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