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
|
771
|
6 ;; Copyright (C) 2001 Ben Wing.
|
428
|
7
|
|
8 ;; Keywords: multilingual, Cyrillic
|
|
9
|
|
10 ;; This file is part of XEmacs.
|
|
11
|
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
15 ;; any later version.
|
|
16
|
|
17 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
|
21
|
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
25 ;; 02111-1307, USA.
|
|
26
|
|
27 ;;; Commentary:
|
|
28
|
771
|
29 ;; The character set ISO8859-5 is supported. KOI-8 and ALTERNATIVNYJ are
|
|
30 ;; converted to ISO8859-5 internally.
|
|
31
|
|
32 ;; Windows-1251 support deleted because XEmacs has automatic support.
|
428
|
33
|
|
34 ;;; Code:
|
|
35
|
444
|
36 ;; Cyrillic syntax
|
428
|
37 (modify-syntax-entry 'cyrillic-iso8859-5 "w")
|
|
38 (modify-syntax-entry ?,L-(B ".")
|
|
39 (modify-syntax-entry ?,Lp(B ".")
|
|
40 (modify-syntax-entry ?,L}(B ".")
|
|
41
|
|
42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
43 ;;; CYRILLIC
|
|
44 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
45
|
444
|
46 ;; ISO-8859-5
|
428
|
47
|
|
48 (make-coding-system
|
|
49 'iso-8859-5 'iso2022
|
771
|
50 "ISO-8859-5 (Cyrillic)"
|
428
|
51 '(charset-g0 ascii
|
|
52 charset-g1 cyrillic-iso8859-5
|
|
53 charset-g2 t
|
|
54 charset-g3 t
|
|
55 mnemonic "ISO8/Cyr"
|
|
56 ))
|
|
57
|
|
58 (set-language-info-alist
|
|
59 "Cyrillic-ISO" '((charset cyrillic-iso8859-5)
|
|
60 (tutorial . "TUTORIAL.ru")
|
|
61 (coding-system iso-8859-5)
|
|
62 (coding-priority iso-8859-5)
|
|
63 (input-method . "cyrillic-yawerty")
|
|
64 (features cyril-util)
|
|
65 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
66 (documentation . "Support for Cyrillic ISO-8859-5."))
|
|
67 '("Cyrillic"))
|
|
68
|
444
|
69 ;; KOI-8
|
428
|
70
|
|
71 (eval-and-compile
|
|
72
|
|
73 (defvar cyrillic-koi8-r-decode-table
|
|
74 [
|
|
75 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
76 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
77 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
78 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
79 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
80 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
81 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
82 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
83 ?$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
|
|
84 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
|
|
85 ?$(G#D(B 32 32 ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 ?$(G#E(B
|
|
86 32 32 ?$(G#G(B ?,L!(B 32 32 32 32 32 32 32 32 ?$(G#F(B 32 32 ?,A)(B
|
|
87 ?,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
|
|
88 ?,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
|
|
89 ?,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
|
|
90 ?,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 ]
|
|
91 "Cyrillic KOI8-R decoding table.")
|
|
92
|
|
93 (defvar cyrillic-koi8-r-encode-table
|
|
94 (let ((table (make-vector 256 32))
|
|
95 (i 0))
|
|
96 (while (< i 256)
|
|
97 (let* ((ch (aref cyrillic-koi8-r-decode-table i))
|
|
98 (split (split-char ch)))
|
|
99 (cond ((eq (car split) 'cyrillic-iso8859-5)
|
|
100 (aset table (logior (nth 1 split) 128) i)
|
|
101 )
|
|
102 ((eq ch 32))
|
|
103 ((eq (car split) 'ascii)
|
|
104 (aset table ch i)
|
|
105 )))
|
|
106 (setq i (1+ i)))
|
|
107 table)
|
|
108 "Cyrillic KOI8-R encoding table.")
|
|
109
|
|
110 )
|
|
111
|
|
112 (define-ccl-program ccl-decode-koi8
|
|
113 `(3
|
|
114 ((read r0)
|
|
115 (loop
|
|
116 (write-read-repeat r0 ,cyrillic-koi8-r-decode-table))))
|
|
117 "CCL program to decode KOI8.")
|
|
118
|
|
119 (define-ccl-program ccl-encode-koi8
|
|
120 `(1
|
|
121 ((read r0)
|
|
122 (loop
|
|
123 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
124 (write-read-repeat r0)
|
|
125 ((read r0)
|
|
126 (write-read-repeat r0 , cyrillic-koi8-r-encode-table))))))
|
|
127 "CCL program to encode KOI8.")
|
|
128
|
|
129 ;; (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
|
|
130 ;; (define-coding-system-alias 'koi8 'cyrillic-koi8)
|
|
131
|
|
132 (make-coding-system
|
|
133 'koi8-r 'ccl
|
771
|
134 "KOI8-R (Cyrillic)"
|
444
|
135 '(decode ccl-decode-koi8
|
|
136 encode ccl-encode-koi8
|
428
|
137 mnemonic "KOI8"))
|
|
138
|
444
|
139 ;; `iso-8-1' is not correct, but XEmacs doesn't have a `ccl' category
|
428
|
140 (coding-system-put 'koi8-r 'category 'iso-8-1)
|
|
141
|
|
142 ;; (define-ccl-program ccl-encode-koi8-font
|
|
143 ;; `(0
|
|
144 ;; ((r1 |= 128)
|
|
145 ;; (r1 = r1 ,cyrillic-koi8-r-encode-table)))
|
|
146 ;; "CCL program to encode Cyrillic chars to KOI font.")
|
|
147
|
|
148 ;; (setq font-ccl-encoder-alist
|
|
149 ;; (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
|
|
150
|
|
151 ;; (defvar cyrillic-koi8-r-nonascii-translation-table
|
|
152 ;; (make-translation-table-from-vector cyrillic-koi8-r-decode-table)
|
|
153 ;; "Value of `nonascii-translation-table' in Cyrillic-KOI8 language environment..")
|
|
154
|
|
155 (set-language-info-alist
|
|
156 "Cyrillic-KOI8" '((charset cyrillic-iso8859-5)
|
|
157 (coding-system koi8-r)
|
|
158 (coding-priority koi8-r)
|
|
159 (input-method . "cyrillic-yawerty")
|
|
160 (features cyril-util)
|
771
|
161 (locale "ru")
|
|
162 (mswindows-locale . "RUSSIAN")
|
428
|
163 (tutorial . "TUTORIAL.ru")
|
|
164 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
165 (documentation . "Support for Cyrillic KOI8-R."))
|
|
166 '("Cyrillic"))
|
|
167
|
771
|
168 ;;; WINDOWS-1251 deleted; we support it automatically in XEmacs
|
444
|
169
|
|
170 ;;; ALTERNATIVNYJ
|
428
|
171
|
|
172 (eval-and-compile
|
|
173
|
|
174 (defvar cyrillic-alternativnyj-decode-table
|
|
175 [
|
|
176 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
177 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
178 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
179 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
180 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
181 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
182 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
183 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
184 ?,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
|
|
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 ?,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
|
|
187 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
188 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
189 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
190 ?,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
|
|
191 ?,L!(B ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 32 32 ?,Lp(B]
|
|
192 "Cyrillic ALTERNATIVNYJ decoding table.")
|
|
193
|
|
194 (defvar cyrillic-alternativnyj-encode-table
|
|
195 (let ((table (make-vector 256 32))
|
|
196 (i 0))
|
|
197 (while (< i 256)
|
|
198 (let* ((ch (aref cyrillic-alternativnyj-decode-table i))
|
|
199 (split (split-char ch)))
|
|
200 (if (eq (car split) 'cyrillic-iso8859-5)
|
|
201 (aset table (logior (nth 1 split) 128) i)
|
|
202 (if (/= ch 32)
|
|
203 (aset table ch i))))
|
|
204 (setq i (1+ i)))
|
|
205 table)
|
|
206 "Cyrillic ALTERNATIVNYJ encoding table.")
|
|
207
|
|
208 )
|
|
209
|
|
210
|
|
211 (define-ccl-program ccl-decode-alternativnyj
|
|
212 `(3
|
|
213 ((read r0)
|
|
214 (loop
|
|
215 (write-read-repeat r0 ,cyrillic-alternativnyj-decode-table))))
|
|
216 "CCL program to decode Alternativnyj.")
|
|
217
|
|
218 (define-ccl-program ccl-encode-alternativnyj
|
|
219 `(1
|
|
220 ((read r0)
|
|
221 (loop
|
|
222 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
223 (write-read-repeat r0)
|
|
224 ((read r0)
|
|
225 (write-read-repeat r0 ,cyrillic-alternativnyj-encode-table))))))
|
|
226 "CCL program to encode Alternativnyj.")
|
|
227
|
|
228 ;; (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
|
|
229
|
|
230 (make-coding-system
|
|
231 'alternativnyj 'ccl
|
771
|
232 "Alternativnyj (Cyrillic)"
|
444
|
233 '(decode ccl-decode-alternativnyj
|
|
234 encode ccl-encode-alternativnyj
|
428
|
235 mnemonic "Cy.Alt"))
|
|
236
|
444
|
237 ;; `iso-8-1' is not correct, but XEmacs doesn't have `ccl' category
|
428
|
238 (coding-system-put 'alternativnyj 'category 'iso-8-1)
|
|
239
|
|
240 ;; (define-ccl-program ccl-encode-alternativnyj-font
|
|
241 ;; '(0
|
|
242 ;; ((r1 |= 128)
|
|
243 ;; (r1 = r1 ,cyrillic-alternativnyj-encode-table)))
|
|
244 ;; "CCL program to encode Cyrillic chars to Alternativnyj font.")
|
|
245
|
|
246 ;; (setq font-ccl-encoder-alist
|
|
247 ;; (cons (cons "alternativnyj" ccl-encode-alternativnyj-font)
|
|
248 ;; font-ccl-encoder-alist))
|
|
249
|
|
250 ;; (defvar cyrillic-alternativnyj-nonascii-translation-table
|
|
251 ;; (make-translation-table-from-vector cyrillic-alternativnyj-decode-table)
|
|
252 ;; "Value of `nonascii-translation-table' in Cyrillic-ALT language environment.")
|
|
253
|
|
254 (set-language-info-alist
|
|
255 "Cyrillic-ALT" '((charset cyrillic-iso8859-5)
|
|
256 (coding-system alternativnyj)
|
|
257 (coding-priority alternativnyj)
|
|
258 (input-method . "cyrillic-yawerty")
|
|
259 (features cyril-util)
|
|
260 (tutorial . "TUTORIAL.ru")
|
|
261 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
262 (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
|
|
263 '("Cyrillic"))
|
|
264
|
|
265 ;;; cyrillic.el ends here
|