(NSIG) [__DJGPP__ == 2 && __DJGPP_MINOR__ == 1]:
[bpt/emacs.git] / lisp / language / cyrillic.el
CommitLineData
56c8bc03 1;;; cyrillic.el --- Support for Cyrillic -*- coding: iso-2022-7bit; -*-
4ed46869 2
4ed46869 3;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
b79e7b7b 4;; Licensed to the Free Software Foundation.
4ed46869
KH
5
6;; Keywords: multilingual, Cyrillic
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation; either version 2, or (at your option)
13;; any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
369314dc
KH
21;; along with GNU Emacs; see the file COPYING. If not, write to the
22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23;; Boston, MA 02111-1307, USA.
4ed46869
KH
24
25;;; Commentary:
26
2b01336d
KH
27;; The character set ISO8859-5 is supported. KOI-8 and ALTERNATIVNYJ
28;; are converted to ISO8859-5 internally.
4ed46869
KH
29
30;;; Code:
31
5f1d80c7
KH
32;; Cyrillic (general)
33
2b01336d
KH
34;; ISO-8859-5 staff
35
4ed46869 36(make-coding-system
efbc7e89
KH
37 'cyrillic-iso-8bit 2 ?5
38 "ISO 2022 based 8-bit encoding for Cyrillic script (MIME:ISO-8859-5)"
11b77f14
KH
39 '(ascii cyrillic-iso8859-5 nil nil
40 nil nil nil nil nil nil nil)
41 '((safe-charsets ascii cyrillic-iso8859-5)
42 (mime-charset . iso-8859-5)))
4ed46869 43
71eabd24 44(define-coding-system-alias 'iso-8859-5 'cyrillic-iso-8bit)
efbc7e89 45
5f1d80c7 46(set-language-info-alist
a564ccf9 47 "Cyrillic-ISO" '((charset cyrillic-iso8859-5)
11b77f14
KH
48 (coding-system cyrillic-iso-8bit)
49 (coding-priority cyrillic-iso-8bit)
a564ccf9
KH
50 (input-method . "cyrillic-yawerty")
51 (nonascii-translation . cyrillic-iso8859-5)
52 (unibyte-display . cyrillic-iso-8bit)
53 (features cyril-util)
5f1d80c7 54 (sample-text . "Russian (\e,L@caaZXY\e(B) \e,L7T`PRabRcYbU\e(B!")
11b77f14
KH
55 (documentation . "Support for Cyrillic ISO-8859-5."))
56 '("Cyrillic"))
5f1d80c7 57
2b01336d
KH
58;; KOI-8 staff
59
70c58a1f
KH
60(defvar cyrillic-koi8-r-decode-table
61 [
62 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
63 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
64 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
65 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
66 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
67 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
68 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
69 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
70 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
71 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
1aee0381
KH
72 160 161 162 ?\e,Lq\e(B 164 165 166 167 168 169 170 171 172 173 174 175
73 176 177 178 ?\e,L!\e(B 180 181 182 183 184 185 186 187 188 189 190 191
70c58a1f
KH
74 ?\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
75 ?\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
76 ?\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
77 ?\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 ]
78 "Cyrillic KOI8-R decoding table.")
79
1f487ef8
KH
80(let ((table (make-translation-table-from-vector
81 cyrillic-koi8-r-decode-table)))
82 (define-translation-table 'cyrillic-koi8-r-nonascii-translation-table table)
83 (define-translation-table 'cyrillic-koi8-r-encode-table
84 (char-table-extra-slot table 0)))
70c58a1f 85
2b01336d 86(define-ccl-program ccl-decode-koi8
70c58a1f 87 `(3
1f487ef8
KH
88 ((loop
89 (r0 = 0)
90 (read r1)
91 (if (r1 < 128)
92 (write-repeat r1)
93 ((translate-character cyrillic-koi8-r-nonascii-translation-table r0 r1)
94 (write-multibyte-character r0 r1)
95 (repeat))))))
2b01336d
KH
96 "CCL program to decode KOI8.")
97
98(define-ccl-program ccl-encode-koi8
99 `(1
1f487ef8
KH
100 ((loop
101 (read-multibyte-character r0 r1)
102 (if (r0 == ,(charset-id 'cyrillic-iso8859-5))
103 (translate-character cyrillic-koi8-r-encode-table r0 r1))
104 (write-repeat r1))))
2b01336d
KH
105 "CCL program to encode KOI8.")
106
107(make-coding-system
4b9121fc 108 'cyrillic-koi8 4
49716ecd
RS
109 ;; We used to use ?K. It is true that ?K is more strictly correct,
110 ;; but it is also used for Korean.
111 ;; So people who use koi8 for languages other than Russian
112 ;; will have to forgive us.
efbc7e89 113 ?R "KOI8 8-bit encoding for Cyrillic (MIME: KOI8-R)"
7fbf766f 114 '(ccl-decode-koi8 . ccl-encode-koi8)
53a1db80
KH
115 `((safe-chars . ,(let ((table (make-char-table 'safe-chars))
116 (i 0))
117 (while (< i 256)
118 (aset table (aref cyrillic-koi8-r-decode-table i) t)
119 (setq i (1+ i)))
120 table))
70c58a1f 121 (mime-charset . koi8-r)
cf461235
KH
122 (valid-codes (0 . 127) 163 179 (192 . 255))
123 (charset-origin-alist (cyrillic-iso8859-5 "KOI8-R"
124 cyrillic-encode-koi8-r-char))))
2b01336d 125
71eabd24
RS
126(define-coding-system-alias 'koi8-r 'cyrillic-koi8)
127(define-coding-system-alias 'koi8 'cyrillic-koi8)
2b01336d
KH
128
129(define-ccl-program ccl-encode-koi8-font
70c58a1f 130 `(0
1f487ef8 131 ((translate-character cyrillic-koi8-r-encode-table r0 r1)))
2b01336d
KH
132 "CCL program to encode Cyrillic chars to KOI font.")
133
134(setq font-ccl-encoder-alist
1f487ef8 135 (cons '("koi8" . ccl-encode-koi8-font) font-ccl-encoder-alist))
70c58a1f 136
5f1d80c7 137(set-language-info-alist
a564ccf9
KH
138 "Cyrillic-KOI8" `((charset cyrillic-iso8859-5)
139 (nonascii-translation
1f487ef8
KH
140 . ,(get 'cyrillic-koi8-r-nonascii-translation-table
141 'translation-table))
11b77f14
KH
142 (coding-system cyrillic-koi8)
143 (coding-priority cyrillic-koi8)
44446f59 144 (input-method . "cyrillic-jcuken")
a564ccf9
KH
145 (features cyril-util)
146 (unibyte-display . cyrillic-koi8)
5f1d80c7 147 (sample-text . "Russian (\e,L@caaZXY\e(B) \e,L7T`PRabRcYbU\e(B!")
70c58a1f 148 (documentation . "Support for Cyrillic KOI8-R."))
11b77f14 149 '("Cyrillic"))
5f1d80c7 150
2b01336d
KH
151;;; ALTERNATIVNYJ staff
152
70c58a1f
KH
153(defvar cyrillic-alternativnyj-decode-table
154 [
155 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
156 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
157 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
158 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
159 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
160 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
161 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
162 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
163 ?\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
164 ?\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
165 ?\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
1aee0381
KH
166 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
167 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
168 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
70c58a1f 169 ?\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
1aee0381 170 ?\e,L!\e(B ?\e,Lq\e(B 242 243 244 245 246 247 248 249 250 251 252 253 254 ?\e,Lp\e(B]
70c58a1f
KH
171 "Cyrillic ALTERNATIVNYJ decoding table.")
172
1f487ef8
KH
173(let ((table (make-translation-table-from-vector
174 cyrillic-alternativnyj-decode-table)))
175 (define-translation-table 'cyrillic-alternativnyj-nonascii-translation-table
70c58a1f 176 table)
1f487ef8
KH
177 (define-translation-table 'cyrillic-alternativnyj-encode-table
178 (char-table-extra-slot table 0)))
70c58a1f
KH
179
180
2b01336d 181(define-ccl-program ccl-decode-alternativnyj
70c58a1f 182 `(3
1f487ef8
KH
183 ((loop
184 (r0 = 0)
185 (read r1)
186 (if (r1 < 128)
187 (write-repeat r1)
188 ((translate-character cyrillic-alternativnyj-nonascii-translation-table
189 r0 r1)
190 (write-multibyte-character r0 r1)
191 (repeat))))))
2b01336d
KH
192 "CCL program to decode Alternativnyj.")
193
194(define-ccl-program ccl-encode-alternativnyj
195 `(1
1f487ef8
KH
196 ((loop
197 (read-multibyte-character r0 r1)
53a1db80 198 (translate-character cyrillic-alternativnyj-encode-table r0 r1)
1f487ef8 199 (write-repeat r1))))
2b01336d
KH
200 "CCL program to encode Alternativnyj.")
201
202(make-coding-system
efbc7e89
KH
203 'cyrillic-alternativnyj 4 ?A
204 "ALTERNATIVNYJ 8-bit encoding for Cyrillic"
7fbf766f 205 '(ccl-decode-alternativnyj . ccl-encode-alternativnyj)
53a1db80
KH
206 `((safe-chars . ,(let ((table (make-char-table 'safe-chars))
207 (i 0))
208 (while (< i 256)
209 (aset table (aref cyrillic-alternativnyj-decode-table i)
210 t)
211 (setq i (1+ i)))
212 table))
cf461235
KH
213 (valid-codes (0 . 175) (224 . 241) 255)
214 (charset-origin-alist (cyrillic-iso8859-5 "ALTERNATIVNYJ"
215 cyrillic-encode-koi8-r-char))))
216
2b01336d 217
71eabd24 218(define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
efbc7e89 219
2b01336d
KH
220(define-ccl-program ccl-encode-alternativnyj-font
221 '(0
1f487ef8 222 ((translate-character cyrillic-alternativnyj-encode-table r0 r1)))
2b01336d
KH
223 "CCL program to encode Cyrillic chars to Alternativnyj font.")
224
225(setq font-ccl-encoder-alist
1f487ef8 226 (cons '("alternativnyj" . ccl-encode-alternativnyj-font)
2b01336d
KH
227 font-ccl-encoder-alist))
228
4ed46869 229(set-language-info-alist
a564ccf9
KH
230 "Cyrillic-ALT" `((charset cyrillic-iso8859-5)
231 (nonascii-translation
1f487ef8
KH
232 . ,(get 'cyrillic-alternativnyj-nonascii-translation-table
233 'translation-table))
11b77f14
KH
234 (coding-system cyrillic-alternativnyj)
235 (coding-priority cyrillic-alternativnyj)
44446f59 236 (input-method . "cyrillic-jcuken")
a564ccf9
KH
237 (features cyril-util)
238 (unibyte-display . cyrillic-alternativnyj)
5f1d80c7 239 (sample-text . "Russian (\e,L@caaZXY\e(B) \e,L7T`PRabRcYbU\e(B!")
11b77f14
KH
240 (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
241 '("Cyrillic"))
4ed46869
KH
242
243;;; cyrillic.el ends here