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
|
3767
|
32 ;; [Windows-1251 support deleted because XEmacs has automatic support.]
|
|
33
|
|
34 ;; #### We only have automatic support on Windows; that needs to be put
|
|
35 ;; back. Also, the Russian Wikipedia articles on KOI-8 list several other
|
|
36 ;; related encodings--KOI8-U (Ukrainian), KOI8-RU (simultaneous support for
|
|
37 ;; Russian, Belorussian, and Ukrainian), KOI8-C (for languages of the
|
|
38 ;; Caucasus), KOI8-O (Old Church Slavonic)--and it would be nice to have
|
|
39 ;; them. Beyond that, we're currently trashing lots of code points with
|
|
40 ;; KOI-8 R; it would be nice to leverage the Unicode support to not do that.
|
428
|
41
|
|
42 ;;; Code:
|
|
43
|
3767
|
44 ;; Case table:
|
3749
|
45 (loop
|
|
46 for (upper lower)
|
|
47 in '((#xcf #xef) ; YA
|
|
48 (#xce #xee) ; YU
|
|
49 (#xcd #xed) ; E
|
|
50 (#xcc #xec) ; SOFT SIGN
|
|
51 (#xcb #xeb) ; YERU
|
|
52 (#xca #xea) ; HARD SIGN
|
|
53 (#xc9 #xe9) ; SHCHA
|
|
54 (#xc8 #xe8) ; SHA
|
|
55 (#xc7 #xe7) ; CHE
|
|
56 (#xc6 #xe6) ; TSE
|
|
57 (#xc5 #xe5) ; HA
|
|
58 (#xc4 #xe4) ; EF
|
|
59 (#xc3 #xe3) ; U
|
|
60 (#xc2 #xe2) ; TE
|
|
61 (#xc1 #xe1) ; ES
|
|
62 (#xc0 #xe0) ; ER
|
|
63 (#xbf #xdf) ; PE
|
|
64 (#xbe #xde) ; O
|
|
65 (#xbd #xdd) ; EN
|
|
66 (#xbc #xdc) ; EM
|
|
67 (#xbb #xdb) ; EL
|
|
68 (#xba #xda) ; KA
|
|
69 (#xb9 #xd9) ; SHORT I
|
|
70 (#xb8 #xd8) ; I
|
|
71 (#xb7 #xd7) ; ZE
|
|
72 (#xb6 #xd6) ; ZHE
|
|
73 (#xb5 #xd5) ; IE
|
|
74 (#xb4 #xd4) ; DE
|
|
75 (#xb3 #xd3) ; GHE
|
|
76 (#xb2 #xd2) ; VE
|
|
77 (#xb1 #xd1) ; BE
|
|
78 (#xb0 #xd0) ; A
|
|
79 (#xaf #xff) ; DZHE
|
|
80 (#xae #xfe) ; SHORT U
|
|
81 (#xac #xfc) ; KJE
|
|
82 (#xab #xfb) ; TSHE
|
|
83 (#xaa #xfa) ; NJE
|
|
84 (#xa9 #xf9) ; LJE
|
|
85 (#xa8 #xf8) ; JE
|
|
86 (#xa7 #xf7) ; YI
|
|
87 (#xa6 #xf6) ; BYELORUSSIAN-UKRAINIAN I
|
|
88 (#xa5 #xf5) ; DZE
|
|
89 (#xa4 #xf4) ; UKRAINIAN IE
|
|
90 (#xa3 #xf3) ; GJE
|
|
91 (#xa2 #xf2) ; DJE
|
|
92 (#xa1 #xf1)) ; IO
|
|
93 with case-table = (standard-case-table)
|
|
94 do
|
|
95 (put-case-table-pair (make-char 'cyrillic-iso8859-5 upper)
|
|
96 (make-char 'cyrillic-iso8859-5 lower)
|
|
97 case-table))
|
|
98
|
|
99 ;; The default character syntax is now word. Pay attention to the
|
3767
|
100 ;; exceptions in ISO-8859-5, copying them from ISO-8859-1.
|
|
101 (loop
|
|
102 for (latin-1 cyrillic)
|
|
103 in '((#xAD #xAD) ;; SOFT HYPHEN
|
|
104 (#xA7 #xFD) ;; SECTION SIGN
|
|
105 (#xA0 #xA0)) ;; NO BREAK SPACE
|
|
106 with syntax-table = (standard-syntax-table)
|
|
107 do (modify-syntax-entry
|
|
108 (make-char 'cyrillic-iso8859-5 cyrillic)
|
|
109 (string (char-syntax (make-char 'latin-iso8859-1 latin-1)))
|
|
110 syntax-table))
|
|
111
|
|
112 ;; Take NUMERO SIGN's syntax from #.
|
|
113 (modify-syntax-entry (make-char 'cyrillic-iso8859-5 #xF0)
|
|
114 (string (char-syntax ?\# (standard-syntax-table)))
|
|
115 (standard-syntax-table))
|
778
|
116
|
428
|
117 (make-coding-system
|
|
118 'iso-8859-5 'iso2022
|
771
|
119 "ISO-8859-5 (Cyrillic)"
|
428
|
120 '(charset-g0 ascii
|
|
121 charset-g1 cyrillic-iso8859-5
|
|
122 charset-g2 t
|
|
123 charset-g3 t
|
3767
|
124 mnemonic "ISO8/Cyr"))
|
428
|
125
|
|
126 (set-language-info-alist
|
|
127 "Cyrillic-ISO" '((charset cyrillic-iso8859-5)
|
|
128 (tutorial . "TUTORIAL.ru")
|
|
129 (coding-system iso-8859-5)
|
3769
|
130 (native-coding-system iso-8859-5)
|
428
|
131 (coding-priority iso-8859-5)
|
|
132 (input-method . "cyrillic-yawerty")
|
|
133 (features cyril-util)
|
|
134 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
135 (documentation . "Support for Cyrillic ISO-8859-5."))
|
|
136 '("Cyrillic"))
|
|
137
|
444
|
138 ;; KOI-8
|
428
|
139
|
|
140 (eval-and-compile
|
|
141
|
|
142 (defvar cyrillic-koi8-r-decode-table
|
|
143 [
|
|
144 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
|
145 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
|
146 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
147 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
148 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
149 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
150 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
151 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
152 ?$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
|
|
153 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
|
|
154 ?$(G#D(B 32 32 ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 ?$(G#E(B
|
|
155 32 32 ?$(G#G(B ?,L!(B 32 32 32 32 32 32 32 32 ?$(G#F(B 32 32 ?,A)(B
|
|
156 ?,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
|
|
157 ?,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
|
|
158 ?,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
|
|
159 ?,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 ]
|
|
160 "Cyrillic KOI8-R decoding table.")
|
|
161
|
|
162 (defvar cyrillic-koi8-r-encode-table
|
|
163 (let ((table (make-vector 256 32))
|
|
164 (i 0))
|
|
165 (while (< i 256)
|
|
166 (let* ((ch (aref cyrillic-koi8-r-decode-table i))
|
|
167 (split (split-char ch)))
|
|
168 (cond ((eq (car split) 'cyrillic-iso8859-5)
|
3767
|
169 (aset table (logior (nth 1 split) 128) i))
|
428
|
170 ((eq ch 32))
|
|
171 ((eq (car split) 'ascii)
|
3767
|
172 (aset table ch i))))
|
428
|
173 (setq i (1+ i)))
|
|
174 table)
|
|
175 "Cyrillic KOI8-R encoding table.")
|
|
176
|
|
177 )
|
|
178
|
|
179 (define-ccl-program ccl-decode-koi8
|
|
180 `(3
|
|
181 ((read r0)
|
|
182 (loop
|
|
183 (write-read-repeat r0 ,cyrillic-koi8-r-decode-table))))
|
|
184 "CCL program to decode KOI8.")
|
|
185
|
|
186 (define-ccl-program ccl-encode-koi8
|
|
187 `(1
|
|
188 ((read r0)
|
|
189 (loop
|
|
190 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
|
|
191 (write-read-repeat r0)
|
|
192 ((read r0)
|
|
193 (write-read-repeat r0 , cyrillic-koi8-r-encode-table))))))
|
|
194 "CCL program to encode KOI8.")
|
|
195
|
|
196 ;; (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
|
|
197 ;; (define-coding-system-alias 'koi8 'cyrillic-koi8)
|
|
198
|
|
199 (make-coding-system
|
|
200 'koi8-r 'ccl
|
771
|
201 "KOI8-R (Cyrillic)"
|
444
|
202 '(decode ccl-decode-koi8
|
|
203 encode ccl-encode-koi8
|
428
|
204 mnemonic "KOI8"))
|
|
205
|
444
|
206 ;; `iso-8-1' is not correct, but XEmacs doesn't have a `ccl' category
|
428
|
207 (coding-system-put 'koi8-r 'category 'iso-8-1)
|
|
208
|
|
209 ;; (define-ccl-program ccl-encode-koi8-font
|
|
210 ;; `(0
|
|
211 ;; ((r1 |= 128)
|
|
212 ;; (r1 = r1 ,cyrillic-koi8-r-encode-table)))
|
|
213 ;; "CCL program to encode Cyrillic chars to KOI font.")
|
|
214
|
|
215 ;; (setq font-ccl-encoder-alist
|
|
216 ;; (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
|
|
217
|
788
|
218 (defvar cyrillic-koi8-r-to-external-code-table
|
|
219 (let ((table (make-char-table 'generic))
|
|
220 (i 0)
|
|
221 (len (length cyrillic-koi8-r-decode-table)))
|
|
222 (while (< i len)
|
|
223 (let ((ch (aref cyrillic-koi8-r-decode-table i)))
|
|
224 (if (characterp ch)
|
|
225 (put-char-table ch i table)))
|
|
226 (incf i)))
|
|
227 "Table to convert from characters to their Koi8-R code.")
|
428
|
228
|
|
229 (set-language-info-alist
|
|
230 "Cyrillic-KOI8" '((charset cyrillic-iso8859-5)
|
|
231 (coding-system koi8-r)
|
3707
|
232 (native-coding-system koi8-r)
|
428
|
233 (coding-priority koi8-r)
|
|
234 (input-method . "cyrillic-yawerty")
|
|
235 (features cyril-util)
|
771
|
236 (locale "ru")
|
|
237 (mswindows-locale . "RUSSIAN")
|
428
|
238 (tutorial . "TUTORIAL.ru")
|
|
239 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
240 (documentation . "Support for Cyrillic KOI8-R."))
|
|
241 '("Cyrillic"))
|
|
242
|
771
|
243 ;;; WINDOWS-1251 deleted; we support it automatically in XEmacs
|
444
|
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
|
771
|
307 "Alternativnyj (Cyrillic)"
|
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
|
788
|
325 (defvar cyrillic-alternativnyj-to-external-code-table
|
|
326 (let ((table (make-char-table 'generic))
|
|
327 (i 0)
|
|
328 (len (length cyrillic-alternativnyj-decode-table)))
|
|
329 (while (< i len)
|
|
330 (let ((ch (aref cyrillic-alternativnyj-decode-table i)))
|
|
331 (if (characterp ch)
|
|
332 (put-char-table ch i table)))
|
|
333 (incf i)))
|
|
334 "Table to convert from characters to their Alternativnyj code.")
|
428
|
335
|
|
336 (set-language-info-alist
|
|
337 "Cyrillic-ALT" '((charset cyrillic-iso8859-5)
|
|
338 (coding-system alternativnyj)
|
3707
|
339 (native-coding-system alternativnyj)
|
428
|
340 (coding-priority alternativnyj)
|
|
341 (input-method . "cyrillic-yawerty")
|
|
342 (features cyril-util)
|
|
343 (tutorial . "TUTORIAL.ru")
|
|
344 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
|
|
345 (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
|
|
346 '("Cyrillic"))
|
|
347
|
|
348 ;;; cyrillic.el ends here
|