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
|
444
|
28 ;; The character set ISO8859-5 is supported.
|
|
29 ;; KOI-8, Windows-1251, and ALTERNATIVNYJ are converted to ISO8859-5
|
|
30 ;; internally.
|
428
|
31
|
|
32 ;;; Code:
|
|
33
|
444
|
34 ;; Cyrillic syntax
|
428
|
35 (modify-syntax-entry 'cyrillic-iso8859-5 "w")
|
|
36 (modify-syntax-entry ?,L-(B ".")
|
|
37 (modify-syntax-entry ?,Lp(B ".")
|
|
38 (modify-syntax-entry ?,L}(B ".")
|
|
39
|
|
40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
41 ;;; CYRILLIC
|
|
42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
43
|
444
|
44 ;; ISO-8859-5
|
428
|
45
|
|
46 (make-coding-system
|
|
47 'iso-8859-5 'iso2022
|
444
|
48 "ISO-8859-5 (ISO 2022 based 8-bit encoding for Cyrillic script)"
|
428
|
49 '(charset-g0 ascii
|
|
50 charset-g1 cyrillic-iso8859-5
|
|
51 charset-g2 t
|
|
52 charset-g3 t
|
|
53 mnemonic "ISO8/Cyr"
|
|
54 ))
|
|
55
|
|
56 (set-language-info-alist
|
|
57 "Cyrillic-ISO" '((charset cyrillic-iso8859-5)
|
|
58 (tutorial . "TUTORIAL.ru")
|
|
59 (coding-system iso-8859-5)
|
|
60 (coding-priority iso-8859-5)
|
|
61 (input-method . "cyrillic-yawerty")
|
|
62 (features cyril-util)
|
|
63 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
64 (documentation . "Support for Cyrillic ISO-8859-5."))
|
|
65 '("Cyrillic"))
|
|
66
|
444
|
67 ;; KOI-8
|
428
|
68
|
|
69 (eval-and-compile
|
|
70
|
|
71 (defvar cyrillic-koi8-r-decode-table
|
|
72 [
|
|
73 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
74 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
75 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
76 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
77 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
78 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
79 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
80 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
81 ?$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
|
|
82 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
|
|
83 ?$(G#D(B 32 32 ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 ?$(G#E(B
|
|
84 32 32 ?$(G#G(B ?,L!(B 32 32 32 32 32 32 32 32 ?$(G#F(B 32 32 ?,A)(B
|
|
85 ?,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
|
|
86 ?,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
|
|
87 ?,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
|
|
88 ?,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 ]
|
|
89 "Cyrillic KOI8-R decoding table.")
|
|
90
|
|
91 (defvar cyrillic-koi8-r-encode-table
|
|
92 (let ((table (make-vector 256 32))
|
|
93 (i 0))
|
|
94 (while (< i 256)
|
|
95 (let* ((ch (aref cyrillic-koi8-r-decode-table i))
|
|
96 (split (split-char ch)))
|
|
97 (cond ((eq (car split) 'cyrillic-iso8859-5)
|
|
98 (aset table (logior (nth 1 split) 128) i)
|
|
99 )
|
|
100 ((eq ch 32))
|
|
101 ((eq (car split) 'ascii)
|
|
102 (aset table ch i)
|
|
103 )))
|
|
104 (setq i (1+ i)))
|
|
105 table)
|
|
106 "Cyrillic KOI8-R encoding table.")
|
|
107
|
|
108 )
|
|
109
|
|
110 (define-ccl-program ccl-decode-koi8
|
|
111 `(3
|
|
112 ((read r0)
|
|
113 (loop
|
|
114 (write-read-repeat r0 ,cyrillic-koi8-r-decode-table))))
|
|
115 "CCL program to decode KOI8.")
|
|
116
|
|
117 (define-ccl-program ccl-encode-koi8
|
|
118 `(1
|
|
119 ((read r0)
|
|
120 (loop
|
|
121 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
122 (write-read-repeat r0)
|
|
123 ((read r0)
|
|
124 (write-read-repeat r0 , cyrillic-koi8-r-encode-table))))))
|
|
125 "CCL program to encode KOI8.")
|
|
126
|
|
127 ;; (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
|
|
128 ;; (define-coding-system-alias 'koi8 'cyrillic-koi8)
|
|
129
|
|
130 (make-coding-system
|
|
131 'koi8-r 'ccl
|
444
|
132 "KOI8-R 8-bit encoding for Cyrillic."
|
|
133 '(decode ccl-decode-koi8
|
|
134 encode ccl-encode-koi8
|
428
|
135 mnemonic "KOI8"))
|
|
136
|
444
|
137 ;; `iso-8-1' is not correct, but XEmacs doesn't have a `ccl' category
|
428
|
138 (coding-system-put 'koi8-r 'category 'iso-8-1)
|
|
139
|
|
140 ;; (define-ccl-program ccl-encode-koi8-font
|
|
141 ;; `(0
|
|
142 ;; ((r1 |= 128)
|
|
143 ;; (r1 = r1 ,cyrillic-koi8-r-encode-table)))
|
|
144 ;; "CCL program to encode Cyrillic chars to KOI font.")
|
|
145
|
|
146 ;; (setq font-ccl-encoder-alist
|
|
147 ;; (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
|
|
148
|
|
149 ;; (defvar cyrillic-koi8-r-nonascii-translation-table
|
|
150 ;; (make-translation-table-from-vector cyrillic-koi8-r-decode-table)
|
|
151 ;; "Value of `nonascii-translation-table' in Cyrillic-KOI8 language environment..")
|
|
152
|
|
153 (set-language-info-alist
|
|
154 "Cyrillic-KOI8" '((charset cyrillic-iso8859-5)
|
|
155 (coding-system koi8-r)
|
|
156 (coding-priority koi8-r)
|
|
157 (input-method . "cyrillic-yawerty")
|
|
158 (features cyril-util)
|
|
159 (tutorial . "TUTORIAL.ru")
|
|
160 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
161 (documentation . "Support for Cyrillic KOI8-R."))
|
|
162 '("Cyrillic"))
|
|
163
|
444
|
164 ;;; WINDOWS-1251
|
|
165
|
|
166 (eval-and-compile
|
|
167
|
|
168 (defvar cyrillic-windows-1251-decode-table
|
|
169 [
|
|
170 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
171 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
172 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
173 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
174 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
175 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
176 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
177 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
178 ?,L"(B ?,L#(B 32 ?,Ls(B 32 32 32 32 32 32 ?,L)(B 32 ?,L*(B ?,L,(B ?,L+(B ?,L/(B ;"
|
|
179 ?,Lr(B 32 32 32 32 32 32 32 32 32 ?,Ly(B 32 ?,Lz(B ?,L|(B ?,L{(B ?,L(B
|
|
180 ?,L (B ?,L.(B ?,L~(B ?,L((B ?,A$(B 32 ?,A&(B ?,L}(B ?,L!(B ?,A)(B ?,L$(B ?,A+(B ?,A,(B ?,L-(B ?,A.(B ?,L'(B
|
|
181 ?,A0(B ?,A1(B ?,L&(B ?,Lv(B 32 ?,A5(B ?,A6(B ?,A7(B ?,Lq(B ?,Lp(B ?,Lt(B ?,A;(B ?,Lx(B ?,L%(B ?,Lu(B ?,Lw(B
|
|
182 ?,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
|
|
183 ?,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
|
|
184 ?,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
|
|
185 ?,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 ]
|
|
186 "Cyrillic Windows-1251 decoding table.")
|
|
187
|
|
188 (defvar cyrillic-windows-1251-encode-table
|
|
189 (let ((table (make-vector 256 32))
|
|
190 (i 0))
|
|
191 (while (< i 256)
|
|
192 (let* ((ch (aref cyrillic-windows-1251-decode-table i))
|
|
193 (split (split-char ch)))
|
|
194 (cond ((eq (car split) 'cyrillic-iso8859-5)
|
|
195 (aset table (logior (nth 1 split) 128) i)
|
|
196 )
|
|
197 ((eq ch 32))
|
|
198 ((eq (car split) 'ascii)
|
|
199 (aset table ch i)
|
|
200 )))
|
|
201 (setq i (1+ i)))
|
|
202 table)
|
|
203 "Cyrillic Windows-1251 encoding table.")
|
|
204
|
|
205 )
|
|
206
|
|
207 (define-ccl-program ccl-decode-windows1251
|
|
208 `(3
|
|
209 ((read r0)
|
|
210 (loop
|
|
211 (write-read-repeat r0 ,cyrillic-windows-1251-decode-table))))
|
|
212 "CCL program to decode Windows-1251.")
|
|
213
|
|
214 (define-ccl-program ccl-encode-windows1251
|
|
215 `(1
|
|
216 ((read r0)
|
|
217 (loop
|
|
218 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
219 (write-read-repeat r0)
|
|
220 ((read r0)
|
|
221 (write-read-repeat r0 , cyrillic-windows-1251-encode-table))))))
|
|
222 "CCL program to encode Windows-1251.")
|
|
223
|
|
224 (make-coding-system
|
|
225 'windows-1251 'ccl
|
|
226 "Coding-system used for Windows-1251."
|
|
227 '(decode ccl-decode-windows1251
|
|
228 encode ccl-encode-windows1251
|
|
229 mnemonic "CyrW"))
|
|
230
|
|
231 ;; `iso-8-1' is not correct, but XEmacs doesn't have a `ccl' category
|
|
232 (coding-system-put 'windows-1251 'category 'iso-8-1)
|
|
233
|
|
234 (set-language-info-alist
|
|
235 "Cyrillic-Win" '((charset cyrillic-iso8859-5)
|
|
236 (coding-system windows-1251)
|
|
237 (coding-priority windows-1251)
|
|
238 (input-method . "cyrillic-yawerty")
|
|
239 (features cyril-util)
|
|
240 (tutorial . "TUTORIAL.ru")
|
|
241 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
242 (documentation . "Support for Cyrillic Windows-1251."))
|
|
243 '("Cyrillic"))
|
|
244
|
|
245 ;;; ALTERNATIVNYJ
|
428
|
246
|
|
247 (eval-and-compile
|
|
248
|
|
249 (defvar cyrillic-alternativnyj-decode-table
|
|
250 [
|
|
251 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
252 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
253 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
254 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
255 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
256 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
257 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
258 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
259 ?,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
|
|
260 ?,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
|
|
261 ?,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
|
|
262 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
263 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
264 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
265 ?,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
|
|
266 ?,L!(B ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 32 32 ?,Lp(B]
|
|
267 "Cyrillic ALTERNATIVNYJ decoding table.")
|
|
268
|
|
269 (defvar cyrillic-alternativnyj-encode-table
|
|
270 (let ((table (make-vector 256 32))
|
|
271 (i 0))
|
|
272 (while (< i 256)
|
|
273 (let* ((ch (aref cyrillic-alternativnyj-decode-table i))
|
|
274 (split (split-char ch)))
|
|
275 (if (eq (car split) 'cyrillic-iso8859-5)
|
|
276 (aset table (logior (nth 1 split) 128) i)
|
|
277 (if (/= ch 32)
|
|
278 (aset table ch i))))
|
|
279 (setq i (1+ i)))
|
|
280 table)
|
|
281 "Cyrillic ALTERNATIVNYJ encoding table.")
|
|
282
|
|
283 )
|
|
284
|
|
285
|
|
286 (define-ccl-program ccl-decode-alternativnyj
|
|
287 `(3
|
|
288 ((read r0)
|
|
289 (loop
|
|
290 (write-read-repeat r0 ,cyrillic-alternativnyj-decode-table))))
|
|
291 "CCL program to decode Alternativnyj.")
|
|
292
|
|
293 (define-ccl-program ccl-encode-alternativnyj
|
|
294 `(1
|
|
295 ((read r0)
|
|
296 (loop
|
|
297 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
298 (write-read-repeat r0)
|
|
299 ((read r0)
|
|
300 (write-read-repeat r0 ,cyrillic-alternativnyj-encode-table))))))
|
|
301 "CCL program to encode Alternativnyj.")
|
|
302
|
|
303 ;; (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
|
|
304
|
|
305 (make-coding-system
|
|
306 'alternativnyj 'ccl
|
|
307 "Coding-system used for Alternativnyj"
|
444
|
308 '(decode ccl-decode-alternativnyj
|
|
309 encode ccl-encode-alternativnyj
|
428
|
310 mnemonic "Cy.Alt"))
|
|
311
|
444
|
312 ;; `iso-8-1' is not correct, but XEmacs doesn't have `ccl' category
|
428
|
313 (coding-system-put 'alternativnyj 'category 'iso-8-1)
|
|
314
|
|
315 ;; (define-ccl-program ccl-encode-alternativnyj-font
|
|
316 ;; '(0
|
|
317 ;; ((r1 |= 128)
|
|
318 ;; (r1 = r1 ,cyrillic-alternativnyj-encode-table)))
|
|
319 ;; "CCL program to encode Cyrillic chars to Alternativnyj font.")
|
|
320
|
|
321 ;; (setq font-ccl-encoder-alist
|
|
322 ;; (cons (cons "alternativnyj" ccl-encode-alternativnyj-font)
|
|
323 ;; font-ccl-encoder-alist))
|
|
324
|
|
325 ;; (defvar cyrillic-alternativnyj-nonascii-translation-table
|
|
326 ;; (make-translation-table-from-vector cyrillic-alternativnyj-decode-table)
|
|
327 ;; "Value of `nonascii-translation-table' in Cyrillic-ALT language environment.")
|
|
328
|
|
329 (set-language-info-alist
|
|
330 "Cyrillic-ALT" '((charset cyrillic-iso8859-5)
|
|
331 (coding-system alternativnyj)
|
|
332 (coding-priority alternativnyj)
|
|
333 (input-method . "cyrillic-yawerty")
|
|
334 (features cyril-util)
|
|
335 (tutorial . "TUTORIAL.ru")
|
|
336 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
337 (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
|
|
338 '("Cyrillic"))
|
|
339
|
|
340 ;;; cyrillic.el ends here
|