aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2002-07-17 18:39:16 +0000
committerDave Love2002-07-17 18:39:16 +0000
commit6f27e0f93307f4810f9b45f22556e03921c6bf66 (patch)
treed4867a35a81bbc36fb5660b3bfe012f5181380bf
parent99edde43bd05242f2a19c59b440edfeed880a74e (diff)
downloademacs-6f27e0f93307f4810f9b45f22556e03921c6bf66.tar.gz
emacs-6f27e0f93307f4810f9b45f22556e03921c6bf66.zip
(cyrillic-koi8-r-decode-table)
(cyrillic-alternativnyj-decode-table): Fill out with mule-unicode. (cyrillic-koi8-r-decode-table): Make unbound after use. (ccl-decode-koi8, ccl-decode-alternativnyj): Change expansion factor. Use utf-8-translation-table-for-decode. (ccl-encode-koi8, ccl-encode-koi8): Don't check r0. (cyrillic-unify-encoding): New function. (cyrillic-koi8): Modify safe-chars, valid-codes. Remove charset-origin-alist. (Cp878, cp866): New alias. (ccl-encode-8859-5-font): New. (font-ccl-encoder-alist): Add ccl-encode-8859-5-font. (ccl-encode-koi8-font, ccl-encode-alternativnyj-font): Remove redundant parens. ("Cyrillic-KOI8"): Add cyrillic-iso-8bit to coding-priority. (cyrillic-koi8-u-decode-table, ccl-decode-koi8-u) (ccl-encode-koi8-u, koi8-u, ccl-encode-koi8-u-font, "Ukrainian"): New. (cyrillic-alternativnyj): Modify safe-chars, add mime-charset. ("Cyrillic-ALT"): Change input method. ("Windows-1251", "Tajik", "Bulgarian", "Belarusian"): New.
-rw-r--r--lisp/language/cyrillic.el326
1 files changed, 266 insertions, 60 deletions
diff --git a/lisp/language/cyrillic.el b/lisp/language/cyrillic.el
index a2f708fbf04..d0e428b4d0e 100644
--- a/lisp/language/cyrillic.el
+++ b/lisp/language/cyrillic.el
@@ -2,8 +2,10 @@
2 2
3;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. 3;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4;; Licensed to the Free Software Foundation. 4;; Licensed to the Free Software Foundation.
5;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
5 6
6;; Keywords: multilingual, Cyrillic 7;; Author: Kenichi Handa <handa@etl.go.jp>
8;; Keywords: multilingual, Cyrillic, i18n
7 9
8;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
9 11
@@ -24,15 +26,33 @@
24 26
25;;; Commentary: 27;;; Commentary:
26 28
27;; The character set ISO8859-5 is supported. See 29;; The character set ISO8859-5 is supported. KOI-8 and ALTERNATIVNYJ
28;; http://www.ecma.ch/ecma1/STAND/ECMA-113.HTM. KOI-8 and 30;; are converted to Unicode internally. See
29;; ALTERNATIVNYJ are converted to ISO8859-5 internally. 31;; <URL:http://www.ecma.ch/ecma1/STAND/ECMA-113.HTM>. For more info
32;; on Cyrillic charsets, see
33;; <URL:http://czyborra.com/charsets/cyrillic.html>. The KOI and
34;; Alternativnyj coding systems should live in code-pages.el, but
35;; they've always been preloaded and the coding system autoload
36;; mechanism didn't get accepted, so they have to stay here and
37;; duplicate code-pages stuff.
38
39;; Note that 8859-5 maps directly onto the Unicode Cyrillic block,
40;; apart from codepoints 160 (NBSP, c.f. U+0400), 173 (soft hyphen,
41;; c.f. U+04OD) and 253 (section sign, c.f U+045D). The KOI-8 and
42;; Alternativnyj coding systems encode both 8859-5 and Unicode.
43;; ucs-tables.el provides unification for cyrillic-iso-8bit.
44
45;; Customizing `utf-8-fragment-on-decoding' allows decoding characters
46;; from KOI and Alternativnyj into 8859-5 where that's possible.
47;; cyrillic-iso8859-5 characters take half as much space in the buffer
48;; as the mule-unicode-0100-24ff equivalents, though that's probably
49;; not normally a big deal.
30 50
31;;; Code: 51;;; Code:
32 52
33;; Cyrillic (general) 53;; Cyrillic (general)
34 54
35;; ISO-8859-5 staff 55;; ISO-8859-5 stuff
36 56
37(make-coding-system 57(make-coding-system
38 'cyrillic-iso-8bit 2 ?5 58 'cyrillic-iso-8bit 2 ?5
@@ -48,7 +68,7 @@
48 "Cyrillic-ISO" '((charset cyrillic-iso8859-5) 68 "Cyrillic-ISO" '((charset cyrillic-iso8859-5)
49 (coding-system cyrillic-iso-8bit) 69 (coding-system cyrillic-iso-8bit)
50 (coding-priority cyrillic-iso-8bit) 70 (coding-priority cyrillic-iso-8bit)
51 (input-method . "cyrillic-yawerty") 71 (input-method . "cyrillic-yawerty") ; fixme
52 (nonascii-translation . cyrillic-iso8859-5) 72 (nonascii-translation . cyrillic-iso8859-5)
53 (unibyte-display . cyrillic-iso-8bit) 73 (unibyte-display . cyrillic-iso-8bit)
54 (features cyril-util) 74 (features cyril-util)
@@ -56,8 +76,11 @@
56 (documentation . "Support for Cyrillic ISO-8859-5.")) 76 (documentation . "Support for Cyrillic ISO-8859-5."))
57 '("Cyrillic")) 77 '("Cyrillic"))
58 78
59;; KOI-8 staff 79;; KOI-8R stuff
60 80
81;; The mule-unicode portion of this is from
82;; http://www.unicode.org/Public/MAPPINGS/VENDORS/MISC/KOI8-R.TXT,
83;; which references RFC 1489.
61(defvar cyrillic-koi8-r-decode-table 84(defvar cyrillic-koi8-r-decode-table
62 [ 85 [
63 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 86 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
@@ -68,14 +91,25 @@
68 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 91 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
69 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 92 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
70 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 93 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
71 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 94 ;; 8859-5 plus Unicode
72 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 95 ?$,2 (B ?$,2 "(B ?$,2 ,(B ?$,2 0(B ?$,2 4(B ?$,2 8(B ?$,2 <(B ?$,2 D(B ?$,2 L(B ?$,2 T(B ?$,2 \(B ?$,2!@(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?$,2!*(B ?$,2!+(B ?$,2!,(B ?,A)(B
108;; ?$,1(n(B ?$,1(P(B ?$,1(Q(B ?$,1(f(B ?$,1(T(B ?$,1(U(B ?$,1(d(B ?$,1(S(B ?$,1(e(B ?$,1(X(B ?$,1(Y(B ?$,1(Z(B ?$,1([(B ?$,1(\(B ?$,1(](B ?$,1(^(B
109;; ?$,1(_(B ?$,1(o(B ?$,1(`(B ?$,1(a(B ?$,1(b(B ?$,1(c(B ?$,1(V(B ?$,1(R(B ?$,1(l(B ?$,1(k(B ?$,1(W(B ?$,1(h(B ?$,1(m(B ?$,1(i(B ?$,1(g(B ?$,1(j(B
110;; ?$,1(N(B ?$,1(0(B ?$,1(1(B ?$,1(F(B ?$,1(4(B ?$,1(5(B ?$,1(D(B ?$,1(3(B ?$,1(E(B ?$,1(8(B ?$,1(9(B ?$,1(:(B ?$,1(;(B ?$,1(<(B ?$,1(=(B ?$,1(>(B
111;; ?$,1(?(B ?$,1(O(B ?$,1(@(B ?$,1(A(B ?$,1(B(B ?$,1(C(B ?$,1(6(B ?$,1(2(B ?$,1(L(B ?$,1(K(B ?$,1(7(B ?$,1(H(B ?$,1(M(B ?$,1(I(B ?$,1(G(B ?$,1(J(B
112 ]
79 "Cyrillic KOI8-R decoding table.") 113 "Cyrillic KOI8-R decoding table.")
80 114
81(let ((table (make-translation-table-from-vector 115(let ((table (make-translation-table-from-vector
@@ -84,57 +118,91 @@
84 (define-translation-table 'cyrillic-koi8-r-encode-table 118 (define-translation-table 'cyrillic-koi8-r-encode-table
85 (char-table-extra-slot table 0))) 119 (char-table-extra-slot table 0)))
86 120
121;; No point in keeping it around. (It can't be let-bound, since it's
122;; needed for macro expansion.)
123(makunbound 'cyrillic-koi8-r-decode-table)
124
87(define-ccl-program ccl-decode-koi8 125(define-ccl-program ccl-decode-koi8
88 `(3 126 `(4
89 ((loop 127 ((loop
90 (r0 = 0) 128 (r0 = 0)
91 (read r1) 129 (read r1)
92 (if (r1 < 128) 130 (if (r1 < 128)
93 (write-repeat r1) 131 (write-repeat r1)
94 ((translate-character cyrillic-koi8-r-nonascii-translation-table r0 r1) 132 ((translate-character cyrillic-koi8-r-nonascii-translation-table r0 r1)
133 (translate-character utf-8-translation-table-for-decode r0 r1)
95 (write-multibyte-character r0 r1) 134 (write-multibyte-character r0 r1)
96 (repeat)))))) 135 (repeat))))))
97 "CCL program to decode KOI8.") 136 "CCL program to decode KOI8-R.")
98 137
99(define-ccl-program ccl-encode-koi8 138(define-ccl-program ccl-encode-koi8
100 `(1 139 `(1
101 ((loop 140 ((loop
102 (read-multibyte-character r0 r1) 141 (read-multibyte-character r0 r1)
103 (if (r0 == ,(charset-id 'cyrillic-iso8859-5)) 142 (translate-character cyrillic-koi8-r-encode-table r0 r1)
104 (translate-character cyrillic-koi8-r-encode-table r0 r1))
105 (write-repeat r1)))) 143 (write-repeat r1))))
106 "CCL program to encode KOI8.") 144 "CCL program to encode KOI8-R.")
107 145
146(defun cyrillic-unify-encoding (table)
147 "Set up equivalent characters in the encoding TABLE.
148This works wheher or not the table is is Unicode-based or
1498859-5-based. (Only appropriate for Cyrillic.)"
150 (let ((table (get table 'translation-table)))
151 (dotimes (i 96)
152 (let* ((c (make-char 'cyrillic-iso8859-5 (+ i 32)))
153 (u ; equivalent Unicode char
154 (cond ((eq c ?,L (B) ?,A (B)
155 ((eq c ?,L-(B) ?,A-(B)
156 ((eq c ?,L}(B) ?,A'(B)
157 (t (decode-char 'ucs (+ #x400 i)))))
158 (ec (aref table c)) ; encoding of 8859-5
159 (uc (aref table u))) ; encoding of Unicode
160 (unless (memq c '(?,L (B ?,L-(B ?,L}(B)) ; 8859-5 exceptions
161 (unless uc
162 (aset table u ec))
163 (unless ec
164 (aset table c uc)))))))
165
166(cyrillic-unify-encoding 'cyrillic-koi8-r-encode-table)
167
108(make-coding-system 168(make-coding-system
109 'cyrillic-koi8 4 169 'cyrillic-koi8 4
110 ;; We used to use ?K. It is true that ?K is more strictly correct, 170 ;; We used to use ?K. It is true that ?K is more strictly correct,
111 ;; but it is also used for Korean. 171 ;; but it is also used for Korean.
112 ;; So people who use koi8 for languages other than Russian 172 ;; So people who use koi8 for languages other than Russian
113 ;; will have to forgive us. 173 ;; will have to forgive us.
114 ?R 174 ?R "KOI8-R 8-bit encoding for Cyrillic (MIME: KOI8-R)."
115 "KOI8 8-bit encoding for Cyrillic (MIME: KOI8-R)."
116 '(ccl-decode-koi8 . ccl-encode-koi8) 175 '(ccl-decode-koi8 . ccl-encode-koi8)
117 `((safe-chars . ,(let ((table (make-char-table 'safe-chars)) 176 `((safe-chars . cyrillic-koi8-r-encode-table)
118 (i 0))
119 (while (< i 256)
120 (aset table (aref cyrillic-koi8-r-decode-table i) t)
121 (setq i (1+ i)))
122 table))
123 (mime-charset . koi8-r) 177 (mime-charset . koi8-r)
124 (valid-codes (0 . 127) 163 179 (192 . 255)) 178 (valid-codes (0 . 255))))
125 (charset-origin-alist (cyrillic-iso8859-5 "KOI8-R"
126 cyrillic-encode-koi8-r-char))))
127 179
128(define-coding-system-alias 'koi8-r 'cyrillic-koi8) 180(define-coding-system-alias 'koi8-r 'cyrillic-koi8)
129(define-coding-system-alias 'koi8 'cyrillic-koi8) 181(define-coding-system-alias 'koi8 'cyrillic-koi8)
182(define-coding-system-alias 'cp878 'cyrillic-koi8)
183
184;; Allow displaying some of KOI & al with an 8859-5-encoded font. We
185;; won't bother about the exceptions when encoding the font, since
186;; NBSP will fall through below and work anyhow, and we'll have
187;; avoided setting the fontset for the other two to 8859-5 -- they're
188;; not in KOI and Alternativnyj anyhow.
189(define-ccl-program ccl-encode-8859-5-font
190 `(0
191 ((if (r0 == ,(charset-id 'cyrillic-iso8859-5))
192 (r1 += 128)
193 (if (r0 == ,(charset-id 'mule-unicode-0100-24ff))
194 (r1 = (r2 + 128))))))
195 "Encode ISO 8859-5 and Cyrillic Unicode chars to 8859-5 font.")
196
197(add-to-list 'font-ccl-encoder-alist '("iso8859-5" . ccl-encode-8859-5-font))
130 198
199;; The table is set up later to encode both Unicode and 8859-5.
131(define-ccl-program ccl-encode-koi8-font 200(define-ccl-program ccl-encode-koi8-font
132 `(0 201 `(0
133 ((translate-character cyrillic-koi8-r-encode-table r0 r1))) 202 (translate-character cyrillic-koi8-r-encode-table r0 r1))
134 "CCL program to encode Cyrillic chars to KOI font.") 203 "CCL program to encode Cyrillic chars to KOI font.")
135 204
136(setq font-ccl-encoder-alist 205(add-to-list 'font-ccl-encoder-alist '("koi8" . ccl-encode-koi8-font))
137 (cons '("koi8" . ccl-encode-koi8-font) font-ccl-encoder-alist))
138 206
139(set-language-info-alist 207(set-language-info-alist
140 "Cyrillic-KOI8" `((charset cyrillic-iso8859-5) 208 "Cyrillic-KOI8" `((charset cyrillic-iso8859-5)
@@ -142,7 +210,7 @@
142 . ,(get 'cyrillic-koi8-r-nonascii-translation-table 210 . ,(get 'cyrillic-koi8-r-nonascii-translation-table
143 'translation-table)) 211 'translation-table))
144 (coding-system cyrillic-koi8) 212 (coding-system cyrillic-koi8)
145 (coding-priority cyrillic-koi8) 213 (coding-priority cyrillic-koi8 cyrillic-iso-8bit)
146 (input-method . "cyrillic-jcuken") 214 (input-method . "cyrillic-jcuken")
147 (features cyril-util) 215 (features cyril-util)
148 (unibyte-display . cyrillic-koi8) 216 (unibyte-display . cyrillic-koi8)
@@ -150,7 +218,97 @@
150 (documentation . "Support for Cyrillic KOI8-R.")) 218 (documentation . "Support for Cyrillic KOI8-R."))
151 '("Cyrillic")) 219 '("Cyrillic"))
152 220
153;;; ALTERNATIVNYJ staff 221
222(defvar cyrillic-koi8-u-decode-table
223 [
224 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
225 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
226 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
227 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
228 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
229 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
230 96 97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Li(B ?,Lg(B ?,Lj(B
248 ?,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
249 ?,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
250 ]
251 "Cyrillic KOI8-U decoding table.")
252
253(let ((table (make-translation-table-from-vector
254 cyrillic-koi8-u-decode-table)))
255 (define-translation-table 'cyrillic-koi8-u-nonascii-translation-table table)
256 (define-translation-table 'cyrillic-koi8-u-encode-table
257 (char-table-extra-slot table 0)))
258
259(makunbound 'cyrillic-koi8-u-decode-table)
260
261(define-ccl-program ccl-decode-koi8-u
262 `(4
263 ((loop
264 (r0 = 0)
265 (read r1)
266 (if (r1 < 128)
267 (write-repeat r1)
268 ((translate-character cyrillic-koi8-u-nonascii-translation-table r0 r1)
269 (translate-character utf-8-translation-table-for-decode r0 r1)
270 (write-multibyte-character r0 r1)
271 (repeat))))))
272 "CCL program to decode KOI8-U.")
273
274(define-ccl-program ccl-encode-koi8-u
275 `(1
276 ((loop
277 (read-multibyte-character r0 r1)
278 (translate-character cyrillic-koi8-u-encode-table r0 r1)
279 (write-repeat r1))))
280 "CCL program to encode KOI8-U.")
281
282(cyrillic-unify-encoding 'cyrillic-koi8-u-encode-table)
283
284(make-coding-system
285 'koi8-u 4
286 ?U "KOI8-U 8-bit encoding for Cyrillic (MIME: KOI8-U)"
287 '(ccl-decode-koi8-u . ccl-encode-koi8-u)
288 `((safe-chars . cyrillic-koi8-u-encode-table)
289 (mime-charset . koi8-u)
290 (valid-codes (0 . 255))))
291
292(define-ccl-program ccl-encode-koi8-u-font
293 `(0
294 (translate-character cyrillic-koi8-u-encode-table r0 r1))
295 "CCL program to encode Cyrillic chars to KOI-U font.")
296
297(add-to-list 'font-ccl-encoder-alist '("koi8-u" . ccl-encode-koi8-u-font))
298
299(set-language-info-alist
300 "Ukrainian" `((coding-system koi8-u)
301 (coding-priority koi8-u)
302 (nonascii-translation
303 . ,(get 'cyrillic-koi8-r-nonascii-translation-table
304 'translation-table))
305 (input-method . "ukrainian-computer")
306 (features code-pages)
307 (documentation
308 . "Support for Ukrainian with koi8-u character set."))
309 '("Cyrillic"))
310
311;;; ALTERNATIVNYJ stuff
154 312
155(defvar cyrillic-alternativnyj-decode-table 313(defvar cyrillic-alternativnyj-decode-table
156 [ 314 [
@@ -162,12 +320,21 @@
162 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 320 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
163 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 321 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
164 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 322 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
323;; ?$,1(0(B ?$,1(1(B ?$,1(2(B ?$,1(3(B ?$,1(4(B ?$,1(5(B ?$,1(6(B ?$,1(7(B ?$,1(8(B ?$,1(9(B ?$,1(:(B ?$,1(;(B ?$,1(<(B ?$,1(=(B ?$,1(>(B ?$,1(?(B
324;; ?$,1(@(B ?$,1(A(B ?$,1(B(B ?$,1(C(B ?$,1(D(B ?$,1(E(B ?$,1(F(B ?$,1(G(B ?$,1(H(B ?$,1(I(B ?$,1(J(B ?$,1(K(B ?$,1(L(B ?$,1(M(B ?$,1(N(B ?$,1(O(B
325;; ?$,1(P(B ?$,1(Q(B ?$,1(R(B ?$,1(S(B ?$,1(T(B ?$,1(U(B ?$,1(V(B ?$,1(W(B ?$,1(X(B ?$,1(Y(B ?$,1(Z(B ?$,1([(B ?$,1(\(B ?$,1(](B ?$,1(^(B ?$,1(_(B
326;; ?$,2!Q(B ?$,2!R(B ?$,2!S(B ?$,2 "(B ?$,2 D(B ?$,2!!(B ?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,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
172 ?,L!(B ?,Lq(B ?,L$(B ?,Lt(B ?,L'(B ?,Lw(B ?,L.(B ?,L~(B 248 249 250 251 ?,Lp(B 253 254 ?,L (B] 339 ?,L!(B ?,Lq(B ?,L$(B ?,Lt(B ?,L'(B ?,Lw(B ?,L.(B ?,L~(B 248 249 250 251 ?,Lp(B 253 254 ?,L (B]
173 "Cyrillic ALTERNATIVNYJ decoding table.") 340 "Cyrillic ALTERNATIVNYJ decoding table.")
@@ -179,9 +346,10 @@
179 (define-translation-table 'cyrillic-alternativnyj-encode-table 346 (define-translation-table 'cyrillic-alternativnyj-encode-table
180 (char-table-extra-slot table 0))) 347 (char-table-extra-slot table 0)))
181 348
349(makunbound 'cyrillic-alternativnyj-decode-table)
182 350
183(define-ccl-program ccl-decode-alternativnyj 351(define-ccl-program ccl-decode-alternativnyj
184 `(3 352 `(4
185 ((loop 353 ((loop
186 (r0 = 0) 354 (r0 = 0)
187 (read r1) 355 (read r1)
@@ -189,6 +357,7 @@
189 (write-repeat r1) 357 (write-repeat r1)
190 ((translate-character cyrillic-alternativnyj-nonascii-translation-table 358 ((translate-character cyrillic-alternativnyj-nonascii-translation-table
191 r0 r1) 359 r0 r1)
360 (translate-character utf-8-translation-table-for-decode r0 r1)
192 (write-multibyte-character r0 r1) 361 (write-multibyte-character r0 r1)
193 (repeat)))))) 362 (repeat))))))
194 "CCL program to decode Alternativnyj.") 363 "CCL program to decode Alternativnyj.")
@@ -200,33 +369,27 @@
200 (translate-character cyrillic-alternativnyj-encode-table r0 r1) 369 (translate-character cyrillic-alternativnyj-encode-table r0 r1)
201 (write-repeat r1)))) 370 (write-repeat r1))))
202 "CCL program to encode Alternativnyj.") 371 "CCL program to encode Alternativnyj.")
203 372
373(cyrillic-unify-encoding 'cyrillic-alternativnyj-encode-table)
374
204(make-coding-system 375(make-coding-system
205 'cyrillic-alternativnyj 4 ?A 376 'cyrillic-alternativnyj 4 ?A
206 "ALTERNATIVNYJ 8-bit encoding for Cyrillic." 377 "ALTERNATIVNYJ (CP866) 8-bit encoding for Cyrillic."
207 '(ccl-decode-alternativnyj . ccl-encode-alternativnyj) 378 '(ccl-decode-alternativnyj . ccl-encode-alternativnyj)
208 `((safe-chars . ,(let ((table (make-char-table 'safe-chars)) 379 `((safe-chars . cyrillic-alternativnyj-encode-table)
209 (i 0)) 380 (valid-codes (0 . 255))
210 (while (< i 256) 381 (mime-charset . cp866)))
211 (aset table (aref cyrillic-alternativnyj-decode-table i)
212 t)
213 (setq i (1+ i)))
214 table))
215 (valid-codes (0 . 175) (224 . 241) 255)
216 (charset-origin-alist (cyrillic-iso8859-5 "ALTERNATIVNYJ"
217 cyrillic-encode-koi8-r-char))))
218
219 382
220(define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj) 383(define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
384(define-coding-system-alias 'cp866 'cyrillic-alternativnyj)
221 385
222(define-ccl-program ccl-encode-alternativnyj-font 386(define-ccl-program ccl-encode-alternativnyj-font
223 '(0 387 `(0
224 ((translate-character cyrillic-alternativnyj-encode-table r0 r1))) 388 (translate-character cyrillic-alternativnyj-encode-table r0 r1))
225 "CCL program to encode Cyrillic chars to Alternativnyj font.") 389 "CCL program to encode Cyrillic chars to Alternativnyj font.")
226 390
227(setq font-ccl-encoder-alist 391(add-to-list 'font-ccl-encoder-alist
228 (cons '("alternativnyj" . ccl-encode-alternativnyj-font) 392 '("alternativnyj" . ccl-encode-alternativnyj-font))
229 font-ccl-encoder-alist))
230 393
231(set-language-info-alist 394(set-language-info-alist
232 "Cyrillic-ALT" `((charset cyrillic-iso8859-5) 395 "Cyrillic-ALT" `((charset cyrillic-iso8859-5)
@@ -235,13 +398,56 @@
235 'translation-table)) 398 'translation-table))
236 (coding-system cyrillic-alternativnyj) 399 (coding-system cyrillic-alternativnyj)
237 (coding-priority cyrillic-alternativnyj) 400 (coding-priority cyrillic-alternativnyj)
238 (input-method . "cyrillic-jcuken") 401 (input-method . "russian-typewriter")
239 (features cyril-util) 402 (features cyril-util)
240 (unibyte-display . cyrillic-alternativnyj) 403 (unibyte-display . cyrillic-alternativnyj)
241 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!") 404 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
242 (documentation . "Support for Cyrillic ALTERNATIVNYJ.")) 405 (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
243 '("Cyrillic")) 406 '("Cyrillic"))
244 407
408(set-language-info-alist
409 "Windows-1251" `((coding-system windows-1251)
410 (coding-priority windows-1251)
411 (nonascii-translation
412 . ,(get 'decode-windows-1252 'translation-table))
413 (input-method . "russian-typewriter") ; fixme?
414 (features code-pages)
415 (documentation . "Support for windows-1251 character set."))
416 '("Cyrillic"))
417
418(set-language-info-alist
419 "Tajik" `((coding-system cyrillic-koi8-t)
420 (coding-priority cyrillic-koi8-t)
421 (nonascii-translation
422 . ,(get 'decode-koi8-t 'translation-table))
423 (input-method . "russian-typewriter") ; fixme?
424 (features code-pages)
425 (documentation . "Support for Tajik using KOI8-T."))
426 '("Cyrillic"))
427
428(set-language-info-alist
429 "Bulgarian" `((coding-system windows-1251)
430 (coding-priority windows-1251)
431 (nonascii-translation
432 . ,(get 'decode-windows-1251 'translation-table))
433 (input-method . "bulgarian-standard")
434 (features code-pages)
435 (documentation
436 . "Support for Bulgrian with windows-1251 character set."))
437 '("Cyrillic"))
438
439(set-language-info-alist
440 "Belarusian" `((coding-system windows-1251)
441 (coding-priority windows-1251)
442 (nonascii-translation
443 . ,(get 'decode-windows-1251 'translation-table))
444 (input-method . "belarusian")
445 (features code-pages)
446 (documentation
447 . "Support for Belarusian with windows-1251 character set.
448\(The name Belarusian replaced Byelorussian in the early 1990s.)"))
449 '("Cyrillic"))
450
245(provide 'cyrillic) 451(provide 'cyrillic)
246 452
247;;; cyrillic.el ends here 453;;; cyrillic.el ends here