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