1 ;;; cyrillic.el --- Support for Cyrillic -*- coding: iso-2022-7bit; -*-
3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
5 ;; Copyright (C) 1997 MORIOKA Tomohiko
7 ;; Keywords: multilingual, Cyrillic
9 ;; This file is part of SXEmacs.
11 ;; SXEmacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; SXEmacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
26 ;; The character set ISO8859-5 is supported.
27 ;; KOI-8, Windows-1251, and ALTERNATIVNYJ are converted to ISO8859-5
31 (eval-when-compile (require 'ccl))
34 (modify-syntax-entry 'cyrillic-iso8859-5 "w")
35 (modify-syntax-entry ?
\e,L-
\e(B ".")
36 (modify-syntax-entry ?
\e,Lp
\e(B ".")
37 (modify-syntax-entry ?
\e,L}
\e(B ".")
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 "ISO-8859-5 (ISO 2022 based 8-bit encoding for Cyrillic script)"
49 charset-g1 cyrillic-iso8859-5
55 (set-language-info-alist
56 "Cyrillic-ISO" '((charset cyrillic-iso8859-5)
57 (tutorial . "TUTORIAL.ru")
58 (coding-system iso-8859-5)
59 (coding-priority iso-8859-5)
60 (input-method . "cyrillic-yawerty")
62 (sample-text . "Russian (
\e,L@caaZXY
\e(B)
\e,L7T`PRabRcYbU
\e(B!")
63 (documentation . "Support for Cyrillic ISO-8859-5."))
70 (defvar cyrillic-koi8-r-decode-table
72 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
73 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
74 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
75 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
76 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
77 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
78 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
79 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
80 ?
\e$B(!
\e(B ?
\e$B("
\e(B ?
\e$B(#
\e(B ?
\e$B($
\e(B ?
\e$B(&
\e(B ?
\e$B(%
\e(B ?
\e$B('
\e(B ?
\e$B()
\e(B ?
\e$B((
\e(B ?
\e$B(*
\e(B ?
\e$B(+
\e(B 32 ?
\e$(G#'
\e(B ?
\e$(G#+
\e(B ?
\e$(G#/
\e(B 32
81 32 ?
\e$(C"F
\e(B 32 32 ?
\e$B"#
\e(B 32 ?
\e$B"e
\e(B ?
\e$A!V
\e(B ?
\e$A!\
\e(B ?
\e$A!]
\e(B ?
\e,L
\e(B 32 ?
\e,A0
\e(B ?
\e,A2
\e(B ?
\e,A7
\e(B ?
\e,Aw
\e(B
82 ?
\e$(G#D
\e(B 32 32 ?
\e,Lq
\e(B 32 32 32 32 32 32 32 32 32 32 32 ?
\e$(G#E
\e(B
83 32 32 ?
\e$(G#G
\e(B ?
\e,L!
\e(B 32 32 32 32 32 32 32 32 ?
\e$(G#F
\e(B 32 32 ?
\e,A)
\e(B
84 ?
\e,Ln
\e(B ?
\e,LP
\e(B ?
\e,LQ
\e(B ?
\e,Lf
\e(B ?
\e,LT
\e(B ?
\e,LU
\e(B ?
\e,Ld
\e(B ?
\e,LS
\e(B ?
\e,Le
\e(B ?
\e,LX
\e(B ?
\e,LY
\e(B ?
\e,LZ
\e(B ?
\e,L[
\e(B ?
\e,L\
\e(B ?
\e,L]
\e(B ?
\e,L^
\e(B
85 ?
\e,L_
\e(B ?
\e,Lo
\e(B ?
\e,L`
\e(B ?
\e,La
\e(B ?
\e,Lb
\e(B ?
\e,Lc
\e(B ?
\e,LV
\e(B ?
\e,LR
\e(B ?
\e,Ll
\e(B ?
\e,Lk
\e(B ?
\e,LW
\e(B ?
\e,Lh
\e(B ?
\e,Lm
\e(B ?
\e,Li
\e(B ?
\e,Lg
\e(B ?
\e,Lj
\e(B
86 ?
\e,LN
\e(B ?
\e,L0
\e(B ?
\e,L1
\e(B ?
\e,LF
\e(B ?
\e,L4
\e(B ?
\e,L5
\e(B ?
\e,LD
\e(B ?
\e,L3
\e(B ?
\e,LE
\e(B ?
\e,L8
\e(B ?
\e,L9
\e(B ?
\e,L:
\e(B ?
\e,L;
\e(B ?
\e,L<
\e(B ?
\e,L=
\e(B ?
\e,L>
\e(B
87 ?
\e,L?
\e(B ?
\e,LO
\e(B ?
\e,L@
\e(B ?
\e,LA
\e(B ?
\e,LB
\e(B ?
\e,LC
\e(B ?
\e,L6
\e(B ?
\e,L2
\e(B ?
\e,LL
\e(B ?
\e,LK
\e(B ?
\e,L7
\e(B ?
\e,LH
\e(B ?
\e,LM
\e(B ?
\e,LI
\e(B ?
\e,LG
\e(B ?
\e,LJ
\e(B ]
88 "Cyrillic KOI8-R decoding table.")
90 (defvar cyrillic-koi8-r-encode-table
91 (let ((table (make-vector 256 32))
94 (let* ((ch (aref cyrillic-koi8-r-decode-table i))
95 (split (split-char ch)))
96 (cond ((eq (car split) 'cyrillic-iso8859-5)
97 (aset table (logior (nth 1 split) 128) i)
100 ((eq (car split) 'ascii)
105 "Cyrillic KOI8-R encoding table.")
109 (define-ccl-program ccl-decode-koi8
113 (write-read-repeat r0 ,cyrillic-koi8-r-decode-table))))
114 "CCL program to decode KOI8.")
116 (define-ccl-program ccl-encode-koi8
120 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
121 (write-read-repeat r0)
123 (write-read-repeat r0 , cyrillic-koi8-r-encode-table))))))
124 "CCL program to encode KOI8.")
126 ;; (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
127 ;; (define-coding-system-alias 'koi8 'cyrillic-koi8)
131 "KOI8-R 8-bit encoding for Cyrillic."
132 '(decode ccl-decode-koi8
133 encode ccl-encode-koi8
136 ;; `iso-8-1' is not correct, but XEmacs doesn't have a `ccl' category
137 (coding-system-put 'koi8-r 'category 'iso-8-1)
139 (define-ccl-program ccl-encode-koi8-r-font
142 (r1 = r1 ,cyrillic-koi8-r-encode-table)))
143 "CCL program to encode Cyrillic chars to koi8-r font.")
145 ;; (setq font-ccl-encoder-alist
146 ;; (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
148 ;; (defvar cyrillic-koi8-r-nonascii-translation-table
149 ;; (make-translation-table-from-vector cyrillic-koi8-r-decode-table)
150 ;; "Value of `nonascii-translation-table' in Cyrillic-KOI8 language environment..")
152 (set-language-info-alist
153 "Cyrillic-KOI8" '((charset cyrillic-iso8859-5)
154 (coding-system koi8-r)
155 (coding-priority koi8-r)
156 (input-method . "cyrillic-yawerty")
157 (features cyril-util)
158 (tutorial . "TUTORIAL.ru")
159 (sample-text . "Russian (
\e,L@caaZXY
\e(B)
\e,L7T`PRabRcYbU
\e(B!")
160 (documentation . "Support for Cyrillic KOI8-R."))
167 (defvar cyrillic-windows-1251-decode-table
169 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
170 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
171 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
172 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
173 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
174 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
175 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
176 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
177 ?
\e,L"
\e(B ?
\e,L#
\e(B 32 ?
\e,Ls
\e(B 32 32 32 32 32 32 ?
\e,L)
\e(B 32 ?
\e,L*
\e(B ?
\e,L,
\e(B ?
\e,L+
\e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(B ?
\e,LU
\e(B ?
\e,LV
\e(B ?
\e,LW
\e(B ?
\e,LX
\e(B ?
\e,LY
\e(B ?
\e,LZ
\e(B ?
\e,L[
\e(B ?
\e,L\
\e(B ?
\e,L]
\e(B ?
\e,L^
\e(B ?
\e,L_
\e(B
184 ?
\e,L`
\e(B ?
\e,La
\e(B ?
\e,Lb
\e(B ?
\e,Lc
\e(B ?
\e,Ld
\e(B ?
\e,Le
\e(B ?
\e,Lf
\e(B ?
\e,Lg
\e(B ?
\e,Lh
\e(B ?
\e,Li
\e(B ?
\e,Lj
\e(B ?
\e,Lk
\e(B ?
\e,Ll
\e(B ?
\e,Lm
\e(B ?
\e,Ln
\e(B ?
\e,Lo
\e(B ]
185 "Cyrillic Windows-1251 decoding table.")
187 (defvar cyrillic-windows-1251-encode-table
188 (let ((table (make-vector 256 32))
191 (let* ((ch (aref cyrillic-windows-1251-decode-table i))
192 (split (split-char ch)))
193 (cond ((eq (car split) 'cyrillic-iso8859-5)
194 (aset table (logior (nth 1 split) 128) i)
197 ((eq (car split) 'ascii)
202 "Cyrillic Windows-1251 encoding table.")
206 (define-ccl-program ccl-decode-windows1251
210 (write-read-repeat r0 ,cyrillic-windows-1251-decode-table))))
211 "CCL program to decode Windows-1251.")
213 (define-ccl-program ccl-encode-windows1251
217 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
218 (write-read-repeat r0)
220 (write-read-repeat r0 , cyrillic-windows-1251-encode-table))))))
221 "CCL program to encode Windows-1251.")
225 "Coding-system used for Windows-1251."
226 '(decode ccl-decode-windows1251
227 encode ccl-encode-windows1251
230 ;; `iso-8-1' is not correct, but XEmacs doesn't have a `ccl' category
231 (coding-system-put 'windows-1251 'category 'iso-8-1)
233 (set-language-info-alist
234 "Cyrillic-Win" '((charset cyrillic-iso8859-5)
235 (coding-system windows-1251)
236 (coding-priority windows-1251)
237 (input-method . "cyrillic-yawerty")
238 (features cyril-util)
239 (tutorial . "TUTORIAL.ru")
240 (sample-text . "Russian (
\e,L@caaZXY
\e(B)
\e,L7T`PRabRcYbU
\e(B!")
241 (documentation . "Support for Cyrillic Windows-1251."))
248 (defvar cyrillic-alternativnyj-decode-table
250 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
251 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
252 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
253 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
254 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
255 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
256 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
257 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
258 ?
\e,L0
\e(B ?
\e,L1
\e(B ?
\e,L2
\e(B ?
\e,L3
\e(B ?
\e,L4
\e(B ?
\e,L5
\e(B ?
\e,L6
\e(B ?
\e,L7
\e(B ?
\e,L8
\e(B ?
\e,L9
\e(B ?
\e,L:
\e(B ?
\e,L;
\e(B ?
\e,L<
\e(B ?
\e,L=
\e(B ?
\e,L>
\e(B ?
\e,L?
\e(B
259 ?
\e,L@
\e(B ?
\e,LA
\e(B ?
\e,LB
\e(B ?
\e,LC
\e(B ?
\e,LD
\e(B ?
\e,LE
\e(B ?
\e,LF
\e(B ?
\e,LG
\e(B ?
\e,LH
\e(B ?
\e,LI
\e(B ?
\e,LJ
\e(B ?
\e,LK
\e(B ?
\e,LL
\e(B ?
\e,LM
\e(B ?
\e,LN
\e(B ?
\e,LO
\e(B
260 ?
\e,LP
\e(B ?
\e,LQ
\e(B ?
\e,LR
\e(B ?
\e,LS
\e(B ?
\e,LT
\e(B ?
\e,LU
\e(B ?
\e,LV
\e(B ?
\e,LW
\e(B ?
\e,LX
\e(B ?
\e,LY
\e(B ?
\e,LZ
\e(B ?
\e,L[
\e(B ?
\e,L\
\e(B ?
\e,L]
\e(B ?
\e,L^
\e(B ?
\e,L_
\e(B
261 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
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 ?
\e,L`
\e(B ?
\e,La
\e(B ?
\e,Lb
\e(B ?
\e,Lc
\e(B ?
\e,Ld
\e(B ?
\e,Le
\e(B ?
\e,Lf
\e(B ?
\e,Lg
\e(B ?
\e,Lh
\e(B ?
\e,Li
\e(B ?
\e,Lj
\e(B ?
\e,Lk
\e(B ?
\e,Ll
\e(B ?
\e,Lm
\e(B ?
\e,Ln
\e(B ?
\e,Lo
\e(B
265 ?
\e,L!
\e(B ?
\e,Lq
\e(B 32 32 32 32 32 32 32 32 32 32 32 32 32 ?
\e,Lp
\e(B]
266 "Cyrillic ALTERNATIVNYJ decoding table.")
268 (defvar cyrillic-alternativnyj-encode-table
269 (let ((table (make-vector 256 32))
272 (let* ((ch (aref cyrillic-alternativnyj-decode-table i))
273 (split (split-char ch)))
274 (if (eq (car split) 'cyrillic-iso8859-5)
275 (aset table (logior (nth 1 split) 128) i)
280 "Cyrillic ALTERNATIVNYJ encoding table.")
285 (define-ccl-program ccl-decode-alternativnyj
289 (write-read-repeat r0 ,cyrillic-alternativnyj-decode-table))))
290 "CCL program to decode Alternativnyj.")
292 (define-ccl-program ccl-encode-alternativnyj
296 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
297 (write-read-repeat r0)
299 (write-read-repeat r0 ,cyrillic-alternativnyj-encode-table))))))
300 "CCL program to encode Alternativnyj.")
302 ;; (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
306 "Coding-system used for Alternativnyj"
307 '(decode ccl-decode-alternativnyj
308 encode ccl-encode-alternativnyj
311 ;; `iso-8-1' is not correct, but XEmacs doesn't have `ccl' category
312 (coding-system-put 'alternativnyj 'category 'iso-8-1)
314 ;; (define-ccl-program ccl-encode-alternativnyj-font
317 ;; (r1 = r1 ,cyrillic-alternativnyj-encode-table)))
318 ;; "CCL program to encode Cyrillic chars to Alternativnyj font.")
320 ;; (setq font-ccl-encoder-alist
321 ;; (cons (cons "alternativnyj" ccl-encode-alternativnyj-font)
322 ;; font-ccl-encoder-alist))
324 ;; (defvar cyrillic-alternativnyj-nonascii-translation-table
325 ;; (make-translation-table-from-vector cyrillic-alternativnyj-decode-table)
326 ;; "Value of `nonascii-translation-table' in Cyrillic-ALT language environment.")
328 (set-language-info-alist
329 "Cyrillic-ALT" '((charset cyrillic-iso8859-5)
330 (coding-system alternativnyj)
331 (coding-priority alternativnyj)
332 (input-method . "cyrillic-yawerty")
333 (features cyril-util)
334 (tutorial . "TUTORIAL.ru")
335 (sample-text . "Russian (
\e,L@caaZXY
\e(B)
\e,L7T`PRabRcYbU
\e(B!")
336 (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
343 ;; FIXME: this defun is cut-and-pasted from mule/latin.el
344 (defun setup-case-pairs (charset pairs)
345 (let ((tbl (standard-case-table)))
346 (loop for (uc lc) in pairs do
347 (put-case-table-pair (make-char charset uc) (make-char charset lc) tbl))))
352 (176 208) ;cyrillic letter a
353 (167 247) ;cyrillic letter yi
354 (205 237) ;cyrillic letter e
355 (174 254) ;cyrillic letter short u
356 (177 209) ;cyrillic letter be
357 (197 229) ;cyrillic letter ha
358 (184 216) ;cyrillic letter i
359 (180 212) ;cyrillic letter de
360 (198 230) ;cyrillic letter tse
361 (206 238) ;cyrillic letter yu
362 (190 222) ;cyrillic letter o
363 (168 248) ;cyrillic letter je
364 (202 234) ;cyrillic letter hard sign
365 (199 231) ;cyrillic letter che
366 (164 244) ;cyrillic letter ukrainian ie
367 (162 242) ;cyrillic letter dje
368 (179 211) ;cyrillic letter ghe
369 (195 227) ;cyrillic letter u
370 (191 223) ;cyrillic letter pe
371 (163 243) ;cyrillic letter gje
372 (194 226) ;cyrillic letter te
373 (172 252) ;cyrillic letter kje
374 (178 210) ;cyrillic letter ve
375 (169 249) ;cyrillic letter lje
376 (200 232) ;cyrillic letter sha
377 (170 250) ;cyrillic letter nje
378 (183 215) ;cyrillic letter ze
379 (165 245) ;cyrillic letter dze
380 (203 235) ;cyrillic letter yeru
381 (201 233) ;cyrillic letter shcha
382 (182 214) ;cyrillic letter zhe
383 (175 255) ;cyrillic letter dzhe
384 (196 228) ;cyrillic letter ef
385 (186 218) ;cyrillic letter ka
386 (204 236) ;cyrillic letter soft sign
387 (181 213) ;cyrillic letter ie
388 (187 219) ;cyrillic letter el
389 (188 220) ;cyrillic letter em
390 (189 221) ;cyrillic letter en
391 (171 251) ;cyrillic letter tshe
392 (192 224) ;cyrillic letter er
393 (161 241) ;cyrillic letter io
394 (166 246) ;cyrillic letter byelorussian-ukrainian i
395 (193 225) ;cyrillic letter es
396 (185 217) ;cyrillic letter short i
397 (207 239) ;cyrillic letter ya
400 ;; This is our utility function; we don't want it in the dumped XEmacs.
402 (fmakunbound 'setup-case-pairs)
404 ;;; cyrillic.el ends here