428
|
1 ;;; cyrillic.el --- Support for Cyrillic -*- coding: iso-2022-7bit; -*-
|
|
2
|
|
3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
|
|
4 ;; Licensed to the Free Software Foundation.
|
|
5 ;; Copyright (C) 1997 MORIOKA Tomohiko
|
|
6
|
|
7 ;; Keywords: multilingual, Cyrillic
|
|
8
|
|
9 ;; This file is part of XEmacs.
|
|
10
|
|
11 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
12 ;; under the terms of the GNU General Public License as published by
|
|
13 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
14 ;; any later version.
|
|
15
|
|
16 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
19 ;; General Public License for more details.
|
|
20
|
|
21 ;; You should have received a copy of the GNU General Public License
|
|
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
24 ;; 02111-1307, USA.
|
|
25
|
|
26 ;;; Commentary:
|
|
27
|
|
28 ;; The character set ISO8859-5 is supported. KOI-8 and ALTERNATIVNYJ
|
|
29 ;; are converted to ISO8859-5 internally.
|
|
30
|
|
31 ;;; Code:
|
|
32
|
|
33 ;; For syntax of Cyrillic
|
|
34 (modify-syntax-entry 'cyrillic-iso8859-5 "w")
|
|
35 (modify-syntax-entry ?,L-(B ".")
|
|
36 (modify-syntax-entry ?,Lp(B ".")
|
|
37 (modify-syntax-entry ?,L}(B ".")
|
|
38
|
|
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
40 ;;; CYRILLIC
|
|
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
42
|
|
43 ;; ISO-8859-5 staff
|
|
44
|
|
45 ;; (make-coding-system
|
|
46 ;; 'cyrillic-iso-8bit 2 ?5
|
|
47 ;; "ISO 2022 based 8-bit encoding for Cyrillic script (MIME:ISO-8859-5)"
|
|
48 ;; '(ascii cyrillic-iso8859-5 nil nil
|
|
49 ;; nil nil nil nil nil nil nil)
|
|
50 ;; '((safe-charsets ascii cyrillic-iso8859-5)
|
|
51 ;; (mime-charset . iso-8859-5)))
|
|
52
|
|
53 ;; (define-coding-system-alias 'iso-8859-5 'cyrillic-iso-8bit)
|
|
54
|
|
55 (make-coding-system
|
|
56 'iso-8859-5 'iso2022
|
|
57 "MIME ISO-8859-5"
|
|
58 '(charset-g0 ascii
|
|
59 charset-g1 cyrillic-iso8859-5
|
|
60 charset-g2 t
|
|
61 charset-g3 t
|
|
62 mnemonic "ISO8/Cyr"
|
|
63 ))
|
|
64
|
|
65 (set-language-info-alist
|
|
66 "Cyrillic-ISO" '((charset cyrillic-iso8859-5)
|
|
67 (tutorial . "TUTORIAL.ru")
|
|
68 (coding-system iso-8859-5)
|
|
69 (coding-priority iso-8859-5)
|
|
70 (input-method . "cyrillic-yawerty")
|
|
71 (features cyril-util)
|
|
72 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
73 (documentation . "Support for Cyrillic ISO-8859-5."))
|
|
74 '("Cyrillic"))
|
|
75
|
|
76 ;; KOI-8 staff
|
|
77
|
|
78 (eval-and-compile
|
|
79
|
|
80 (defvar cyrillic-koi8-r-decode-table
|
|
81 [
|
|
82 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
83 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
84 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
85 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
86 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
87 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
88 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
89 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
90 ?$B(!(B ?$B("(B ?$B(#(B ?$B($(B ?$B(&(B ?$B(%(B ?$B('(B ?$B()(B ?$B(((B ?$B(*(B ?$B(+(B 32 ?$(G#'(B ?$(G#+(B ?$(G#/(B 32
|
|
91 32 ?$(C"F(B 32 32 ?$B"#(B 32 ?$B"e(B ?$A!V(B ?$A!\(B ?$A!](B ?,L (B 32 ?,A0(B ?,A2(B ?,A7(B ?,Aw(B
|
|
92 ?$(G#D(B 32 32 ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 ?$(G#E(B
|
|
93 32 32 ?$(G#G(B ?,L!(B 32 32 32 32 32 32 32 32 ?$(G#F(B 32 32 ?,A)(B
|
|
94 ?,Ln(B ?,LP(B ?,LQ(B ?,Lf(B ?,LT(B ?,LU(B ?,Ld(B ?,LS(B ?,Le(B ?,LX(B ?,LY(B ?,LZ(B ?,L[(B ?,L\(B ?,L](B ?,L^(B
|
|
95 ?,L_(B ?,Lo(B ?,L`(B ?,La(B ?,Lb(B ?,Lc(B ?,LV(B ?,LR(B ?,Ll(B ?,Lk(B ?,LW(B ?,Lh(B ?,Lm(B ?,Li(B ?,Lg(B ?,Lj(B
|
|
96 ?,LN(B ?,L0(B ?,L1(B ?,LF(B ?,L4(B ?,L5(B ?,LD(B ?,L3(B ?,LE(B ?,L8(B ?,L9(B ?,L:(B ?,L;(B ?,L<(B ?,L=(B ?,L>(B
|
|
97 ?,L?(B ?,LO(B ?,L@(B ?,LA(B ?,LB(B ?,LC(B ?,L6(B ?,L2(B ?,LL(B ?,LK(B ?,L7(B ?,LH(B ?,LM(B ?,LI(B ?,LG(B ?,LJ(B ]
|
|
98 "Cyrillic KOI8-R decoding table.")
|
|
99
|
|
100 (defvar cyrillic-koi8-r-encode-table
|
|
101 (let ((table (make-vector 256 32))
|
|
102 (i 0))
|
|
103 (while (< i 256)
|
|
104 (let* ((ch (aref cyrillic-koi8-r-decode-table i))
|
|
105 (split (split-char ch)))
|
|
106 (cond ((eq (car split) 'cyrillic-iso8859-5)
|
|
107 (aset table (logior (nth 1 split) 128) i)
|
|
108 )
|
|
109 ((eq ch 32))
|
|
110 ((eq (car split) 'ascii)
|
|
111 (aset table ch i)
|
|
112 )))
|
|
113 (setq i (1+ i)))
|
|
114 table)
|
|
115 "Cyrillic KOI8-R encoding table.")
|
|
116
|
|
117 )
|
|
118
|
|
119 (define-ccl-program ccl-decode-koi8
|
|
120 `(3
|
|
121 ((read r0)
|
|
122 (loop
|
|
123 (write-read-repeat r0 ,cyrillic-koi8-r-decode-table))))
|
|
124 "CCL program to decode KOI8.")
|
|
125
|
|
126 (define-ccl-program ccl-encode-koi8
|
|
127 `(1
|
|
128 ((read r0)
|
|
129 (loop
|
|
130 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
131 (write-read-repeat r0)
|
|
132 ((read r0)
|
|
133 (write-read-repeat r0 , cyrillic-koi8-r-encode-table))))))
|
|
134 "CCL program to encode KOI8.")
|
|
135
|
|
136 ;; (make-coding-system
|
|
137 ;; 'cyrillic-koi8 4
|
|
138 ;; ;; We used to use ?K. It is true that ?K is more strictly correct,
|
|
139 ;; ;; but it is also used for Korean.
|
|
140 ;; ;; So people who use koi8 for languages other than Russian
|
|
141 ;; ;; will have to forgive us.
|
|
142 ;; ?R "KOI8 8-bit encoding for Cyrillic (MIME: KOI8-R)"
|
|
143 ;; '(ccl-decode-koi8 . ccl-encode-koi8)
|
|
144 ;; '((safe-charsets ascii cyrillic-iso8859-5)
|
|
145 ;; (mime-charset . koi8-r)
|
|
146 ;; (valid-codes (0 . 127) 163 179 (192 . 255))
|
|
147 ;; (charset-origin-alist (cyrillic-iso8859-5 "KOI8-R"
|
|
148 ;; cyrillic-encode-koi8-r-char))))
|
|
149
|
|
150 ;; (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
|
|
151 ;; (define-coding-system-alias 'koi8 'cyrillic-koi8)
|
|
152
|
|
153 (make-coding-system
|
|
154 'koi8-r 'ccl
|
|
155 "Coding-system used for KOI8-R."
|
|
156 `(decode ,ccl-decode-koi8
|
|
157 encode ,ccl-encode-koi8
|
|
158 mnemonic "KOI8"))
|
|
159
|
|
160 ;; it is not correct, but XEmacs doesn't have `ccl' category...
|
|
161 (coding-system-put 'koi8-r 'category 'iso-8-1)
|
|
162
|
|
163 ;; (define-ccl-program ccl-encode-koi8-font
|
|
164 ;; `(0
|
|
165 ;; ((r1 |= 128)
|
|
166 ;; (r1 = r1 ,cyrillic-koi8-r-encode-table)))
|
|
167 ;; "CCL program to encode Cyrillic chars to KOI font.")
|
|
168
|
|
169 ;; (setq font-ccl-encoder-alist
|
|
170 ;; (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
|
|
171
|
|
172 ;; (defvar cyrillic-koi8-r-nonascii-translation-table
|
|
173 ;; (make-translation-table-from-vector cyrillic-koi8-r-decode-table)
|
|
174 ;; "Value of `nonascii-translation-table' in Cyrillic-KOI8 language environment..")
|
|
175
|
|
176 (set-language-info-alist
|
|
177 "Cyrillic-KOI8" '((charset cyrillic-iso8859-5)
|
|
178 (coding-system koi8-r)
|
|
179 (coding-priority koi8-r)
|
|
180 (input-method . "cyrillic-yawerty")
|
|
181 (features cyril-util)
|
|
182 (tutorial . "TUTORIAL.ru")
|
|
183 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
184 (documentation . "Support for Cyrillic KOI8-R."))
|
|
185 '("Cyrillic"))
|
|
186
|
|
187 ;;; ALTERNATIVNYJ staff
|
|
188
|
|
189 (eval-and-compile
|
|
190
|
|
191 (defvar cyrillic-alternativnyj-decode-table
|
|
192 [
|
|
193 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
194 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
195 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
196 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
197 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
198 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
199 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
200 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
201 ?,L0(B ?,L1(B ?,L2(B ?,L3(B ?,L4(B ?,L5(B ?,L6(B ?,L7(B ?,L8(B ?,L9(B ?,L:(B ?,L;(B ?,L<(B ?,L=(B ?,L>(B ?,L?(B
|
|
202 ?,L@(B ?,LA(B ?,LB(B ?,LC(B ?,LD(B ?,LE(B ?,LF(B ?,LG(B ?,LH(B ?,LI(B ?,LJ(B ?,LK(B ?,LL(B ?,LM(B ?,LN(B ?,LO(B
|
|
203 ?,LP(B ?,LQ(B ?,LR(B ?,LS(B ?,LT(B ?,LU(B ?,LV(B ?,LW(B ?,LX(B ?,LY(B ?,LZ(B ?,L[(B ?,L\(B ?,L](B ?,L^(B ?,L_(B
|
|
204 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
205 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
206 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
207 ?,L`(B ?,La(B ?,Lb(B ?,Lc(B ?,Ld(B ?,Le(B ?,Lf(B ?,Lg(B ?,Lh(B ?,Li(B ?,Lj(B ?,Lk(B ?,Ll(B ?,Lm(B ?,Ln(B ?,Lo(B
|
|
208 ?,L!(B ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 32 32 ?,Lp(B]
|
|
209 "Cyrillic ALTERNATIVNYJ decoding table.")
|
|
210
|
|
211 (defvar cyrillic-alternativnyj-encode-table
|
|
212 (let ((table (make-vector 256 32))
|
|
213 (i 0))
|
|
214 (while (< i 256)
|
|
215 (let* ((ch (aref cyrillic-alternativnyj-decode-table i))
|
|
216 (split (split-char ch)))
|
|
217 (if (eq (car split) 'cyrillic-iso8859-5)
|
|
218 (aset table (logior (nth 1 split) 128) i)
|
|
219 (if (/= ch 32)
|
|
220 (aset table ch i))))
|
|
221 (setq i (1+ i)))
|
|
222 table)
|
|
223 "Cyrillic ALTERNATIVNYJ encoding table.")
|
|
224
|
|
225 )
|
|
226
|
|
227
|
|
228 (define-ccl-program ccl-decode-alternativnyj
|
|
229 `(3
|
|
230 ((read r0)
|
|
231 (loop
|
|
232 (write-read-repeat r0 ,cyrillic-alternativnyj-decode-table))))
|
|
233 "CCL program to decode Alternativnyj.")
|
|
234
|
|
235 (define-ccl-program ccl-encode-alternativnyj
|
|
236 `(1
|
|
237 ((read r0)
|
|
238 (loop
|
|
239 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
240 (write-read-repeat r0)
|
|
241 ((read r0)
|
|
242 (write-read-repeat r0 ,cyrillic-alternativnyj-encode-table))))))
|
|
243 "CCL program to encode Alternativnyj.")
|
|
244
|
|
245 ;; (make-coding-system
|
|
246 ;; 'cyrillic-alternativnyj 4 ?A
|
|
247 ;; "ALTERNATIVNYJ 8-bit encoding for Cyrillic"
|
|
248 ;; '(ccl-decode-alternativnyj . ccl-encode-alternativnyj)
|
|
249 ;; '((safe-charsets ascii cyrillic-iso8859-5)
|
|
250 ;; (valid-codes (0 . 175) (224 . 241) 255)
|
|
251 ;; (charset-origin-alist (cyrillic-iso8859-5 "ALTERNATIVNYJ"
|
|
252 ;; cyrillic-encode-koi8-r-char))))
|
|
253
|
|
254
|
|
255 ;; (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
|
|
256
|
|
257 (make-coding-system
|
|
258 'alternativnyj 'ccl
|
|
259 "Coding-system used for Alternativnyj"
|
|
260 `(decode ,ccl-decode-alternativnyj
|
|
261 encode ,ccl-encode-alternativnyj
|
|
262 mnemonic "Cy.Alt"))
|
|
263
|
|
264 ;; it is not correct, but XEmacs doesn't have `ccl' category...
|
|
265 (coding-system-put 'alternativnyj 'category 'iso-8-1)
|
|
266
|
|
267 ;; (define-ccl-program ccl-encode-alternativnyj-font
|
|
268 ;; '(0
|
|
269 ;; ((r1 |= 128)
|
|
270 ;; (r1 = r1 ,cyrillic-alternativnyj-encode-table)))
|
|
271 ;; "CCL program to encode Cyrillic chars to Alternativnyj font.")
|
|
272
|
|
273 ;; (setq font-ccl-encoder-alist
|
|
274 ;; (cons (cons "alternativnyj" ccl-encode-alternativnyj-font)
|
|
275 ;; font-ccl-encoder-alist))
|
|
276
|
|
277 ;; (defvar cyrillic-alternativnyj-nonascii-translation-table
|
|
278 ;; (make-translation-table-from-vector cyrillic-alternativnyj-decode-table)
|
|
279 ;; "Value of `nonascii-translation-table' in Cyrillic-ALT language environment.")
|
|
280
|
|
281 (set-language-info-alist
|
|
282 "Cyrillic-ALT" '((charset cyrillic-iso8859-5)
|
|
283 (coding-system alternativnyj)
|
|
284 (coding-priority alternativnyj)
|
|
285 (input-method . "cyrillic-yawerty")
|
|
286 (features cyril-util)
|
|
287 (tutorial . "TUTORIAL.ru")
|
|
288 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
289 (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
|
|
290 '("Cyrillic"))
|
|
291
|
|
292 ;;; cyrillic.el ends here
|