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
|
788
|
6 ;; Copyright (C) 2001, 2002 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
|
778
|
48 ; (make-charset 'cyrillic-iso8859-5
|
|
49 ; "Right-Hand Part of Latin/Cyrillic Alphabet (ISO/IEC 8859-5): ISO-IR-144"
|
|
50 ; '(dimension
|
|
51 ; 1
|
|
52 ; registry "ISO8859-5"
|
|
53 ; chars 96
|
|
54 ; columns 1
|
|
55 ; direction l2r
|
|
56 ; final ?L
|
|
57 ; graphic 1
|
|
58 ; short-name "RHP of ISO8859/5"
|
|
59 ; long-name "RHP of Cyrillic (ISO 8859-5): ISO-IR-144"
|
|
60 ; ))
|
|
61
|
428
|
62 (make-coding-system
|
|
63 'iso-8859-5 'iso2022
|
771
|
64 "ISO-8859-5 (Cyrillic)"
|
428
|
65 '(charset-g0 ascii
|
|
66 charset-g1 cyrillic-iso8859-5
|
|
67 charset-g2 t
|
|
68 charset-g3 t
|
|
69 mnemonic "ISO8/Cyr"
|
|
70 ))
|
|
71
|
|
72 (set-language-info-alist
|
|
73 "Cyrillic-ISO" '((charset cyrillic-iso8859-5)
|
|
74 (tutorial . "TUTORIAL.ru")
|
|
75 (coding-system iso-8859-5)
|
|
76 (coding-priority iso-8859-5)
|
|
77 (input-method . "cyrillic-yawerty")
|
|
78 (features cyril-util)
|
|
79 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
80 (documentation . "Support for Cyrillic ISO-8859-5."))
|
|
81 '("Cyrillic"))
|
|
82
|
444
|
83 ;; KOI-8
|
428
|
84
|
|
85 (eval-and-compile
|
|
86
|
|
87 (defvar cyrillic-koi8-r-decode-table
|
|
88 [
|
|
89 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
90 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
91 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
92 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
93 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
94 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
96 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
97 ?$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
|
|
98 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
|
|
99 ?$(G#D(B 32 32 ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 ?$(G#E(B
|
|
100 32 32 ?$(G#G(B ?,L!(B 32 32 32 32 32 32 32 32 ?$(G#F(B 32 32 ?,A)(B
|
|
101 ?,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
|
|
102 ?,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
|
|
103 ?,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
|
|
104 ?,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 ]
|
|
105 "Cyrillic KOI8-R decoding table.")
|
|
106
|
|
107 (defvar cyrillic-koi8-r-encode-table
|
|
108 (let ((table (make-vector 256 32))
|
|
109 (i 0))
|
|
110 (while (< i 256)
|
|
111 (let* ((ch (aref cyrillic-koi8-r-decode-table i))
|
|
112 (split (split-char ch)))
|
|
113 (cond ((eq (car split) 'cyrillic-iso8859-5)
|
|
114 (aset table (logior (nth 1 split) 128) i)
|
|
115 )
|
|
116 ((eq ch 32))
|
|
117 ((eq (car split) 'ascii)
|
|
118 (aset table ch i)
|
|
119 )))
|
|
120 (setq i (1+ i)))
|
|
121 table)
|
|
122 "Cyrillic KOI8-R encoding table.")
|
|
123
|
|
124 )
|
|
125
|
|
126 (define-ccl-program ccl-decode-koi8
|
|
127 `(3
|
|
128 ((read r0)
|
|
129 (loop
|
|
130 (write-read-repeat r0 ,cyrillic-koi8-r-decode-table))))
|
|
131 "CCL program to decode KOI8.")
|
|
132
|
|
133 (define-ccl-program ccl-encode-koi8
|
|
134 `(1
|
|
135 ((read r0)
|
|
136 (loop
|
|
137 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
138 (write-read-repeat r0)
|
|
139 ((read r0)
|
|
140 (write-read-repeat r0 , cyrillic-koi8-r-encode-table))))))
|
|
141 "CCL program to encode KOI8.")
|
|
142
|
|
143 ;; (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
|
|
144 ;; (define-coding-system-alias 'koi8 'cyrillic-koi8)
|
|
145
|
|
146 (make-coding-system
|
|
147 'koi8-r 'ccl
|
771
|
148 "KOI8-R (Cyrillic)"
|
444
|
149 '(decode ccl-decode-koi8
|
|
150 encode ccl-encode-koi8
|
428
|
151 mnemonic "KOI8"))
|
|
152
|
444
|
153 ;; `iso-8-1' is not correct, but XEmacs doesn't have a `ccl' category
|
428
|
154 (coding-system-put 'koi8-r 'category 'iso-8-1)
|
|
155
|
|
156 ;; (define-ccl-program ccl-encode-koi8-font
|
|
157 ;; `(0
|
|
158 ;; ((r1 |= 128)
|
|
159 ;; (r1 = r1 ,cyrillic-koi8-r-encode-table)))
|
|
160 ;; "CCL program to encode Cyrillic chars to KOI font.")
|
|
161
|
|
162 ;; (setq font-ccl-encoder-alist
|
|
163 ;; (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
|
|
164
|
788
|
165 (defvar cyrillic-koi8-r-to-external-code-table
|
|
166 (let ((table (make-char-table 'generic))
|
|
167 (i 0)
|
|
168 (len (length cyrillic-koi8-r-decode-table)))
|
|
169 (while (< i len)
|
|
170 (let ((ch (aref cyrillic-koi8-r-decode-table i)))
|
|
171 (if (characterp ch)
|
|
172 (put-char-table ch i table)))
|
|
173 (incf i)))
|
|
174 "Table to convert from characters to their Koi8-R code.")
|
428
|
175
|
|
176 (set-language-info-alist
|
|
177 "Cyrillic-KOI8" '((charset cyrillic-iso8859-5)
|
|
178 (coding-system koi8-r)
|
3707
|
179 (native-coding-system koi8-r)
|
428
|
180 (coding-priority koi8-r)
|
|
181 (input-method . "cyrillic-yawerty")
|
|
182 (features cyril-util)
|
771
|
183 (locale "ru")
|
|
184 (mswindows-locale . "RUSSIAN")
|
428
|
185 (tutorial . "TUTORIAL.ru")
|
|
186 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
187 (documentation . "Support for Cyrillic KOI8-R."))
|
|
188 '("Cyrillic"))
|
|
189
|
771
|
190 ;;; WINDOWS-1251 deleted; we support it automatically in XEmacs
|
444
|
191
|
|
192 ;;; ALTERNATIVNYJ
|
428
|
193
|
|
194 (eval-and-compile
|
|
195
|
|
196 (defvar cyrillic-alternativnyj-decode-table
|
|
197 [
|
|
198 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
199 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
200 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
201 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
202 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
203 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
204 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
205 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
206 ?,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
|
|
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 ?,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
|
|
209 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
210 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
211 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
|
|
212 ?,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
|
|
213 ?,L!(B ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 32 32 ?,Lp(B]
|
|
214 "Cyrillic ALTERNATIVNYJ decoding table.")
|
|
215
|
|
216 (defvar cyrillic-alternativnyj-encode-table
|
|
217 (let ((table (make-vector 256 32))
|
|
218 (i 0))
|
|
219 (while (< i 256)
|
|
220 (let* ((ch (aref cyrillic-alternativnyj-decode-table i))
|
|
221 (split (split-char ch)))
|
|
222 (if (eq (car split) 'cyrillic-iso8859-5)
|
|
223 (aset table (logior (nth 1 split) 128) i)
|
|
224 (if (/= ch 32)
|
|
225 (aset table ch i))))
|
|
226 (setq i (1+ i)))
|
|
227 table)
|
|
228 "Cyrillic ALTERNATIVNYJ encoding table.")
|
|
229
|
|
230 )
|
|
231
|
|
232
|
|
233 (define-ccl-program ccl-decode-alternativnyj
|
|
234 `(3
|
|
235 ((read r0)
|
|
236 (loop
|
|
237 (write-read-repeat r0 ,cyrillic-alternativnyj-decode-table))))
|
|
238 "CCL program to decode Alternativnyj.")
|
|
239
|
|
240 (define-ccl-program ccl-encode-alternativnyj
|
|
241 `(1
|
|
242 ((read r0)
|
|
243 (loop
|
|
244 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
245 (write-read-repeat r0)
|
|
246 ((read r0)
|
|
247 (write-read-repeat r0 ,cyrillic-alternativnyj-encode-table))))))
|
|
248 "CCL program to encode Alternativnyj.")
|
|
249
|
|
250 ;; (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
|
|
251
|
|
252 (make-coding-system
|
|
253 'alternativnyj 'ccl
|
771
|
254 "Alternativnyj (Cyrillic)"
|
444
|
255 '(decode ccl-decode-alternativnyj
|
|
256 encode ccl-encode-alternativnyj
|
428
|
257 mnemonic "Cy.Alt"))
|
|
258
|
444
|
259 ;; `iso-8-1' is not correct, but XEmacs doesn't have `ccl' category
|
428
|
260 (coding-system-put 'alternativnyj 'category 'iso-8-1)
|
|
261
|
|
262 ;; (define-ccl-program ccl-encode-alternativnyj-font
|
|
263 ;; '(0
|
|
264 ;; ((r1 |= 128)
|
|
265 ;; (r1 = r1 ,cyrillic-alternativnyj-encode-table)))
|
|
266 ;; "CCL program to encode Cyrillic chars to Alternativnyj font.")
|
|
267
|
|
268 ;; (setq font-ccl-encoder-alist
|
|
269 ;; (cons (cons "alternativnyj" ccl-encode-alternativnyj-font)
|
|
270 ;; font-ccl-encoder-alist))
|
|
271
|
788
|
272 (defvar cyrillic-alternativnyj-to-external-code-table
|
|
273 (let ((table (make-char-table 'generic))
|
|
274 (i 0)
|
|
275 (len (length cyrillic-alternativnyj-decode-table)))
|
|
276 (while (< i len)
|
|
277 (let ((ch (aref cyrillic-alternativnyj-decode-table i)))
|
|
278 (if (characterp ch)
|
|
279 (put-char-table ch i table)))
|
|
280 (incf i)))
|
|
281 "Table to convert from characters to their Alternativnyj code.")
|
428
|
282
|
|
283 (set-language-info-alist
|
|
284 "Cyrillic-ALT" '((charset cyrillic-iso8859-5)
|
|
285 (coding-system alternativnyj)
|
3707
|
286 (native-coding-system alternativnyj)
|
428
|
287 (coding-priority alternativnyj)
|
|
288 (input-method . "cyrillic-yawerty")
|
|
289 (features cyril-util)
|
|
290 (tutorial . "TUTORIAL.ru")
|
|
291 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
292 (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
|
|
293 '("Cyrillic"))
|
|
294
|
|
295 ;;; cyrillic.el ends here
|