/[emacs]/emacs/lisp/language/cyrillic.el
ViewVC logotype

Diff of /emacs/lisp/language/cyrillic.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.31 by pj, Wed Jun 5 05:07:58 2002 UTC revision 1.31.2.1 by miles, Fri Apr 4 06:20:26 2003 UTC
# Line 2  Line 2 
2    
3  ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.  ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4  ;; Licensed to the Free Software Foundation.  ;; Licensed to the Free Software Foundation.
5    ;; Copyright (C) 2001, 2002, 2003  Free Software Foundation, Inc.
6    
7  ;; Keywords: multilingual, Cyrillic  ;; Author: Kenichi Handa <handa@etl.go.jp>
8    ;; Keywords: multilingual, Cyrillic, i18n
9    
10  ;; This file is part of GNU Emacs.  ;; This file is part of GNU Emacs.
11    
# Line 24  Line 26 
26    
27  ;;; Commentary:  ;;; Commentary:
28    
29  ;; The character set ISO8859-5 is supported.  See  ;; The character set ISO8859-5 is supported.  KOI-8 and ALTERNATIVNYJ
30  ;; http://www.ecma.ch/ecma1/STAND/ECMA-113.HTM.  KOI-8 and  ;; are converted to Unicode internally.  See
31  ;; ALTERNATIVNYJ are converted to ISO8859-5 internally.  ;; <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-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.
50    
51  ;;; Code:  ;;; Code:
52    
53  ;; Cyrillic (general)  ;; Cyrillic (general)
54    
55  ;; ISO-8859-5 staff  ;; ISO-8859-5 stuff
56    
57  (make-coding-system  (make-coding-system
58   'cyrillic-iso-8bit 2 ?5   'cyrillic-iso-8bit 2 ?5
59   "ISO 2022 based 8-bit encoding for Cyrillic script (MIME:ISO-8859-5)."   "ISO 2022 based 8-bit encoding for Cyrillic script (MIME:ISO-8859-5)."
60   '(ascii cyrillic-iso8859-5  nil nil   '(ascii cyrillic-iso8859-5  nil nil
61     nil nil nil nil nil nil nil)     nil nil nil nil nil nil nil nil nil nil nil t)
62   '((safe-charsets ascii cyrillic-iso8859-5)   '((safe-charsets ascii cyrillic-iso8859-5)
63     (mime-charset . iso-8859-5)))     (mime-charset . iso-8859-5)))
64    
# Line 48  Line 68 
68   "Cyrillic-ISO" '((charset cyrillic-iso8859-5)   "Cyrillic-ISO" '((charset cyrillic-iso8859-5)
69                    (coding-system cyrillic-iso-8bit)                    (coding-system cyrillic-iso-8bit)
70                    (coding-priority cyrillic-iso-8bit)                    (coding-priority cyrillic-iso-8bit)
71                    (input-method . "cyrillic-yawerty")                    (input-method . "cyrillic-yawerty") ; fixme
72                    (nonascii-translation . cyrillic-iso8859-5)                    (nonascii-translation . cyrillic-iso8859-5)
73                    (unibyte-display . cyrillic-iso-8bit)                    (unibyte-display . cyrillic-iso-8bit)
74                    (features cyril-util)                    (features cyril-util)
# Line 56  Line 76 
76                    (documentation . "Support for Cyrillic ISO-8859-5."))                    (documentation . "Support for Cyrillic ISO-8859-5."))
77   '("Cyrillic"))   '("Cyrillic"))
78    
79  ;; KOI-8 staff  ;; KOI-8R stuff
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.
84  (defvar cyrillic-koi8-r-decode-table  (defvar cyrillic-koi8-r-decode-table
85    [    [
86     0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15     0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Line 68  Line 91 
91     80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95     80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
92     96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111     96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
93     112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127     112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
94     128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143     ;; 8859-5 plus Unicode
95     144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159     ?$,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!@(B ?$,2!D(B ?$,2!H(B ?$,2!L(B ?$,2!P(B
96     160 161 162 ?,Lq(B  164 165 166 167 168 169 170 171 172 173 174 175     ?$,2!Q(B ?$,2!R(B ?$,2!S(B ?$,1{ (B ?$,2!`(B ?$,1s"(B ?$,1x:(B ?$,1xh(B ?$,1y$(B ?$,1y%(B ?,L (B ?$,1{!(B ?,A0(B ?,A2(B ?,A7(B ?,Aw(B
97     176 177 178 ?,L!(B  180 181 182 183 184 185 186 187 188 189 190 191     ?$,2 p(B ?$,2 q(B ?$,2 r(B ?,Lq(B ?$,2 s(B ?$,2 t(B ?$,2 u(B ?$,2 v(B ?$,2 w(B ?$,2 x(B ?$,2 y(B ?$,2 z(B ?$,2 {(B ?$,2 |(B ?$,2 }(B ?$,2 ~(B
98     ?,Ln(B  ?,LP(B  ?,LQ(B  ?,Lf(B  ?,LT(B  ?,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?$,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       ]
113    "Cyrillic KOI8-R decoding table.")    "Cyrillic KOI8-R decoding table.")
114    
115  (let ((table (make-translation-table-from-vector  (let ((table (make-translation-table-from-vector
# Line 84  Line 118 
118    (define-translation-table 'cyrillic-koi8-r-encode-table    (define-translation-table 'cyrillic-koi8-r-encode-table
119      (char-table-extra-slot table 0)))      (char-table-extra-slot table 0)))
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    
125  (define-ccl-program ccl-decode-koi8  (define-ccl-program ccl-decode-koi8
126    `(3    `(4
127      ((loop      ((loop
128        (r0 = 0)        (r0 = 0)
129        (read r1)        (read r1)
130        (if (r1 < 128)        (if (r1 < 128)
131            (write-repeat r1)            (write-repeat r1)
132          ((translate-character cyrillic-koi8-r-nonascii-translation-table r0 r1)          ((translate-character cyrillic-koi8-r-nonascii-translation-table r0 r1)
133             (translate-character ucs-translation-table-for-decode r0 r1)
134           (write-multibyte-character r0 r1)           (write-multibyte-character r0 r1)
135           (repeat))))))           (repeat))))))
136    "CCL program to decode KOI8.")    "CCL program to decode KOI8-R.")
137    
138  (define-ccl-program ccl-encode-koi8  (define-ccl-program ccl-encode-koi8
139    `(1    `(1
140      ((loop      ((loop
141        (read-multibyte-character r0 r1)        (read-multibyte-character r0 r1)
142        (if (r0 == ,(charset-id 'cyrillic-iso8859-5))        (translate-character cyrillic-koi8-r-encode-table r0 r1)
143            (translate-character cyrillic-koi8-r-encode-table r0 r1))        (if (r0 != ,(charset-id 'ascii))
144              (if (r0 != ,(charset-id 'eight-bit-graphic))
145                  (if (r0 != ,(charset-id 'eight-bit-control))
146                      (r1 = ??))))
147        (write-repeat r1))))        (write-repeat r1))))
148    "CCL program to encode KOI8.")    "CCL program to encode KOI8-R.")
149                
150    (defun cyrillic-unify-encoding (table)
151      "Set up equivalent characters in the encoding TABLE.
152    This works whether or not the table is Unicode-based or
153    8859-5-based.  (Only appropriate for Cyrillic.)"
154      (let ((table (get table 'translation-table)))
155        (dotimes (i 96)
156          (let* ((c (make-char 'cyrillic-iso8859-5 (+ i 32)))
157                 (u                         ; equivalent Unicode char
158                  (cond ((eq c ?,L (B) ?,A (B)
159                        ((eq c ?,L-(B) ?,A-(B)
160                        ((eq c ?,L}(B) ?,A'(B)
161                        (t (decode-char 'ucs (+ #x400 i)))))
162                 (ec (aref table c))        ; encoding of 8859-5
163                 (uc (aref table u)))       ; encoding of Unicode
164            (unless (memq c '(?,L (B ?,L-(B ?,L}(B))  ; 8859-5 exceptions
165              (unless uc
166                (aset table u ec))
167              (unless ec
168                (aset table c uc)))))))
169    
170    (cyrillic-unify-encoding 'cyrillic-koi8-r-encode-table)
171    
172  (make-coding-system  (make-coding-system
173   'cyrillic-koi8 4   'cyrillic-koi8 4
174   ;; We used to use ?K.  It is true that ?K is more strictly correct,   ;; We used to use ?K.  It is true that ?K is more strictly correct,
175   ;; but it is also used for Korean.   ;; but it is also used for Korean.
176   ;; So people who use koi8 for languages other than Russian   ;; So people who use koi8 for languages other than Russian
177   ;; will have to forgive us.   ;; will have to forgive us.
178   ?R   ?R "KOI8-R 8-bit encoding for Cyrillic (MIME: KOI8-R)."
  "KOI8 8-bit encoding for Cyrillic (MIME: KOI8-R)."  
179   '(ccl-decode-koi8 . ccl-encode-koi8)   '(ccl-decode-koi8 . ccl-encode-koi8)
180   `((safe-chars . ,(let ((table (make-char-table 'safe-chars))   `((safe-chars . cyrillic-koi8-r-encode-table)
                         (i 0))  
                     (while (< i 256)  
                       (aset table (aref cyrillic-koi8-r-decode-table i) t)  
                       (setq i (1+ i)))  
                     table))  
181     (mime-charset . koi8-r)     (mime-charset . koi8-r)
182     (valid-codes (0 . 127) 163 179 (192 . 255))     (valid-codes (0 . 255))
183     (charset-origin-alist (cyrillic-iso8859-5 "KOI8-R"     (dependency unify-8859-on-encoding-mode unify-8859-on-decoding-mode)))
                                              cyrillic-encode-koi8-r-char))))  
184    
185  (define-coding-system-alias 'koi8-r 'cyrillic-koi8)  (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
186  (define-coding-system-alias 'koi8 'cyrillic-koi8)  (define-coding-system-alias 'koi8 'cyrillic-koi8)
187    (define-coding-system-alias 'cp878 'cyrillic-koi8)
188    
189    ;; Allow displaying some of KOI & al with an 8859-5-encoded font.  We
190    ;; won't bother about the exceptions when encoding the font, since
191    ;; NBSP will fall through below and work anyhow, and we'll have
192    ;; avoided setting the fontset for the other two to 8859-5 -- they're
193    ;; not in KOI and Alternativnyj anyhow.
194    (define-ccl-program ccl-encode-8859-5-font
195      `(0
196        ((if (r0 == ,(charset-id 'cyrillic-iso8859-5))
197             (r1 += 128)
198           (if (r0 == ,(charset-id 'mule-unicode-0100-24ff))
199               (r1 = (r2 + 128))))))
200      "Encode ISO 8859-5 and Cyrillic Unicode chars to 8859-5 font.")
201    
202    (add-to-list 'font-ccl-encoder-alist '("iso8859-5" . ccl-encode-8859-5-font))
203    
204    ;; The table is set up later to encode both Unicode and 8859-5.
205  (define-ccl-program ccl-encode-koi8-font  (define-ccl-program ccl-encode-koi8-font
206    `(0    `(0
207      ((translate-character cyrillic-koi8-r-encode-table r0 r1)))      (translate-character cyrillic-koi8-r-encode-table r0 r1))
208    "CCL program to encode Cyrillic chars to KOI font.")    "CCL program to encode Cyrillic chars to KOI font.")
209    
210  (setq font-ccl-encoder-alist  (add-to-list 'font-ccl-encoder-alist '("koi8" . ccl-encode-koi8-font))
       (cons '("koi8" . ccl-encode-koi8-font) font-ccl-encoder-alist))  
211    
212  (set-language-info-alist  (set-language-info-alist
213   "Cyrillic-KOI8" `((charset cyrillic-iso8859-5)   "Cyrillic-KOI8" `((charset cyrillic-iso8859-5)
# Line 142  Line 215 
215                      . ,(get 'cyrillic-koi8-r-nonascii-translation-table                      . ,(get 'cyrillic-koi8-r-nonascii-translation-table
216                              'translation-table))                              'translation-table))
217                     (coding-system cyrillic-koi8)                     (coding-system cyrillic-koi8)
218                     (coding-priority cyrillic-koi8)                     (coding-priority cyrillic-koi8 cyrillic-iso-8bit)
219                     (input-method . "cyrillic-jcuken")                     (input-method . "russian-typewriter")
220                     (features cyril-util)                     (features cyril-util)
221                     (unibyte-display . cyrillic-koi8)                     (unibyte-display . cyrillic-koi8)
222                     (sample-text . "Russian (,L@caaZXY(B)      ,L7T`PRabRcYbU(B!")                     (sample-text . "Russian (,L@caaZXY(B)      ,L7T`PRabRcYbU(B!")
223                     (documentation . "Support for Cyrillic KOI8-R."))                     (documentation . "Support for Cyrillic KOI8-R."))
224   '("Cyrillic"))   '("Cyrillic"))
225    
226  ;;; ALTERNATIVNYJ staff  (set-language-info-alist
227     "Russian" `((charset cyrillic-iso8859-5)
228                 (nonascii-translation
229                  . ,(get 'cyrillic-koi8-r-nonascii-translation-table
230                          'translation-table))
231                 (coding-system cyrillic-koi8)
232                 (coding-priority cyrillic-koi8 cyrillic-iso-8bit)
233                 (input-method . "russian-computer")
234                 (features cyril-util)
235                 (unibyte-display . cyrillic-koi8)
236                 (sample-text . "Russian (,L@caaZXY(B)    ,L7T`PRabRcYbU(B!")
237                 (documentation . "\
238    Support for Russian using koi8-r and the russian-computer input method.")
239                 (tutorial . "TUTORIAL.ru"))
240     '("Cyrillic"))
241    
242    
243    (defvar cyrillic-koi8-u-decode-table
244      [
245       0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
246       16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
247       32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
248       48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
249       64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
250       80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
251       96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
252       112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
253       ;; All Unicode:
254    ;;    ?$,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!@(B ?$,2!D(B ?$,2!H(B ?$,2!L(B ?$,2!P(B
255    ;;    ?$,2!Q(B ?$,2!R(B ?$,2!S(B ?$,1{ (B ?$,2!`(B ?$,1x9(B ?$,1x:(B ?$,1xh(B ?$,1y$(B ?$,1y%(B ?,L (B ?$,1{!(B ?,A0(B ?,A2(B ?,A7(B ?,Aw(B
256    ;;    ?$,2 p(B ?$,2 q(B ?$,2 r(B ?$,1(q(B ?$,1(t(B ?$,2 t(B ?$,1(v(B ?$,1(w(B ?$,2 w(B ?$,2 x(B ?$,2 y(B ?$,2 z(B ?$,2 {(B ?$,1)Q(B ?$,2 }(B ?$,2 ~(B
257    ;;    ?$,2 (B ?$,2! (B ?$,2!!(B ?$,1(!(B ?$,1($(B ?$,2!#(B ?$,1(&(B ?$,1('(B ?$,2!&(B ?$,2!'(B ?$,2!((B ?$,2!)(B ?$,2!*(B ?$,1)P(B ?$,2!,(B ?,A)(B
258    ;;    ?$,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
259    ;;    ?$,1(_(B ?$,1(o(B ?$,1(`(B ?$,1(a(B ?$,1(b(B ?$,1(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(B ?,Ld(B ?,LS(B ?,Le(B ?,LX(B ?,LY(B ?,LZ(B ?,L[(B ?,L\(B ?,L](B ?,L^(B
268       ?,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
269       ?,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
270       ?,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
271       ]
272      "Cyrillic KOI8-U decoding table.")
273    
274    (let ((table (make-translation-table-from-vector
275                  cyrillic-koi8-u-decode-table)))
276      (define-translation-table 'cyrillic-koi8-u-nonascii-translation-table table)
277      (define-translation-table 'cyrillic-koi8-u-encode-table
278        (char-table-extra-slot table 0)))
279    
280    (makunbound 'cyrillic-koi8-u-decode-table)
281    
282    (define-ccl-program ccl-decode-koi8-u
283      `(4
284        ((loop
285          (r0 = 0)
286          (read r1)
287          (if (r1 < 128)
288              (write-repeat r1)
289            ((translate-character cyrillic-koi8-u-nonascii-translation-table r0 r1)
290             (translate-character ucs-translation-table-for-decode r0 r1)
291             (write-multibyte-character r0 r1)
292             (repeat))))))
293      "CCL program to decode KOI8-U.")
294    
295    (define-ccl-program ccl-encode-koi8-u
296      `(1
297        ((loop
298          (read-multibyte-character r0 r1)
299          (translate-character cyrillic-koi8-u-encode-table r0 r1)
300          (if (r0 != ,(charset-id 'ascii))
301              (if (r0 != ,(charset-id 'eight-bit-graphic))
302                  (if (r0 != ,(charset-id 'eight-bit-control))
303                      (r1 = ??))))
304          (write-repeat r1))))
305      "CCL program to encode KOI8-U.")
306    
307    (cyrillic-unify-encoding 'cyrillic-koi8-u-encode-table)
308    
309    (make-coding-system
310     'koi8-u 4
311     ?U "KOI8-U 8-bit encoding for Cyrillic (MIME: KOI8-U)"
312     '(ccl-decode-koi8-u . ccl-encode-koi8-u)
313     `((safe-chars . cyrillic-koi8-u-encode-table)
314       (mime-charset . koi8-u)
315       (valid-codes (0 . 255))
316       (dependency unify-8859-on-encoding-mode unify-8859-on-decoding-mode)))
317    
318    (define-ccl-program ccl-encode-koi8-u-font
319      `(0
320        (translate-character cyrillic-koi8-u-encode-table r0 r1))
321      "CCL program to encode Cyrillic chars to KOI-U font.")
322    
323    (add-to-list 'font-ccl-encoder-alist '("koi8-u" . ccl-encode-koi8-u-font))
324    
325    (set-language-info-alist
326     "Ukrainian" `((coding-system koi8-u)
327                   (coding-priority koi8-u)
328                   (nonascii-translation
329                    . ,(get 'cyrillic-koi8-u-nonascii-translation-table
330                            'translation-table))
331                   (input-method . "ukrainian-computer")
332                   (features code-pages)
333                   (documentation
334                    . "Support for Ukrainian with KOI8-U character set."))
335     '("Cyrillic"))
336    
337    ;;; ALTERNATIVNYJ stuff
338    
339    ;; Fixme: It's unclear what's the correct table.  I've found
340    ;; statements both that it's the same as cp866 and somewhat different,
341    ;; but nothing that looks really definitive.
342  (defvar cyrillic-alternativnyj-decode-table  (defvar cyrillic-alternativnyj-decode-table
343    [    [
344     0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15     0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
# Line 162  Line 349 
349     80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95     80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95
350     96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111     96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111
351     112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127     112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
352    ;;    ?$,1(0(B  ?$,1(1(B  ?$,1(2(B  ?$,1(3(B  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](B  ?,L^(B  ?,L_(B
364     176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191     ?$,2!Q(B  ?$,2!R(B  ?$,2!S(B  ?$,2 "(B  ?$,2 D(B  ?$,2!!(B  ?$,2!"(B  ?$,2 v(B  ?$,2 u(B  ?$,2!#(B  ?$,2 q(B  ?$,2 w(B  ?$,2 }(B  ?$,2 |(B  ?$,2 {(B  ?$,2 0(B
365     192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207     ?$,2 4(B  ?$,2 T(B  ?$,2 L(B  ?$,2 <(B  ?$,2  (B  ?$,2 \(B  ?$,2 ~(B  ?$,2 (B  ?$,2 z(B  ?$,2 t(B  ?$,2!)(B  ?$,2!&(B  ?$,2! (B  ?$,2 p(B  ?$,2!,(B  ?$,2!'(B
366     208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223     ?$,2!((B  ?$,2!$(B  ?$,2!%(B  ?$,2 y(B  ?$,2 x(B  ?$,2 r(B  ?$,2 s(B  ?$,2!+(B  ?$,2!*(B  ?$,2 8(B  ?$,2 ,(B  ?$,2!H(B  ?$,2!D(B  ?$,2!L(B  ?$,2!P(B  ?$,2!@(B
367     ?,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     ?,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
368     ?,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]     ;; Taken from http://www.cyrillic.com/ref/cyrillic/koi-8alt.html
369       ;; with guesses for the Unicodes of the glyphs in the absence of a
370       ;; table.
371       ?,L!(B  ?,Lq(B  ?$,1ry(B  ?$,1rx(B  ?$,1%A(B  ?$,1%@(B  ?$,1s:(B  ?$,1s9(B  ?$,1vq(B  ?$,1vs(B  ?,A1(B  ?,Aw(B  ?,Lp(B  ?,A$(B  ?$,2!`(B  ?,L (B]
372    "Cyrillic ALTERNATIVNYJ decoding table.")    "Cyrillic ALTERNATIVNYJ decoding table.")
373    
374  (let ((table (make-translation-table-from-vector  (let ((table (make-translation-table-from-vector
# Line 179  Line 378 
378    (define-translation-table 'cyrillic-alternativnyj-encode-table    (define-translation-table 'cyrillic-alternativnyj-encode-table
379      (char-table-extra-slot table 0)))      (char-table-extra-slot table 0)))
380    
381    (makunbound 'cyrillic-alternativnyj-decode-table)
382    
383  (define-ccl-program ccl-decode-alternativnyj  (define-ccl-program ccl-decode-alternativnyj
384    `(3    `(4
385      ((loop      ((loop
386        (r0 = 0)        (r0 = 0)
387        (read r1)        (read r1)
# Line 189  Line 389 
389            (write-repeat r1)            (write-repeat r1)
390          ((translate-character cyrillic-alternativnyj-nonascii-translation-table          ((translate-character cyrillic-alternativnyj-nonascii-translation-table
391                                r0 r1)                                r0 r1)
392             (translate-character ucs-translation-table-for-decode r0 r1)
393           (write-multibyte-character r0 r1)           (write-multibyte-character r0 r1)
394           (repeat))))))           (repeat))))))
395    "CCL program to decode Alternativnyj.")    "CCL program to decode Alternativnyj.")
# Line 198  Line 399 
399      ((loop      ((loop
400        (read-multibyte-character r0 r1)        (read-multibyte-character r0 r1)
401        (translate-character cyrillic-alternativnyj-encode-table r0 r1)        (translate-character cyrillic-alternativnyj-encode-table r0 r1)
402          (if (r0 != ,(charset-id 'ascii))
403              (if (r0 != ,(charset-id 'eight-bit-graphic))
404                  (if (r0 != ,(charset-id 'eight-bit-control))
405                      (r1 = ??))))
406        (write-repeat r1))))        (write-repeat r1))))
407    "CCL program to encode Alternativnyj.")    "CCL program to encode Alternativnyj.")
408                
409    (cyrillic-unify-encoding 'cyrillic-alternativnyj-encode-table)
410    
411  (make-coding-system  (make-coding-system
412   'cyrillic-alternativnyj 4 ?A   'cyrillic-alternativnyj 4 ?A
413   "ALTERNATIVNYJ 8-bit encoding for Cyrillic."   "ALTERNATIVNYJ 8-bit encoding for Cyrillic."
414   '(ccl-decode-alternativnyj . ccl-encode-alternativnyj)   '(ccl-decode-alternativnyj . ccl-encode-alternativnyj)
415   `((safe-chars . ,(let ((table (make-char-table 'safe-chars))   `((safe-chars . cyrillic-alternativnyj-encode-table)
416                          (i 0))     (valid-codes (0 . 255))
417                      (while (< i 256)     (dependency unify-8859-on-encoding-mode unify-8859-on-decoding-mode)))
                       (aset table (aref cyrillic-alternativnyj-decode-table i)  
                             t)  
                       (setq i (1+ i)))  
                     table))  
    (valid-codes (0 . 175) (224 . 241) 255)  
    (charset-origin-alist (cyrillic-iso8859-5 "ALTERNATIVNYJ"  
                                              cyrillic-encode-koi8-r-char))))  
   
418    
419  (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)  (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
420    
421  (define-ccl-program ccl-encode-alternativnyj-font  (define-ccl-program ccl-encode-alternativnyj-font
422    '(0    `(0
423      ((translate-character cyrillic-alternativnyj-encode-table r0 r1)))      (translate-character cyrillic-alternativnyj-encode-table r0 r1))
424    "CCL program to encode Cyrillic chars to Alternativnyj font.")    "CCL program to encode Cyrillic chars to Alternativnyj font.")
425    
426  (setq font-ccl-encoder-alist  (add-to-list 'font-ccl-encoder-alist
427        (cons '("alternativnyj" . ccl-encode-alternativnyj-font)               '("alternativnyj" . ccl-encode-alternativnyj-font))
             font-ccl-encoder-alist))  
428    
429  (set-language-info-alist  (set-language-info-alist
430   "Cyrillic-ALT" `((charset cyrillic-iso8859-5)   "Cyrillic-ALT" `((charset cyrillic-iso8859-5)
# Line 235  Line 433 
433                             'translation-table))                             'translation-table))
434                    (coding-system cyrillic-alternativnyj)                    (coding-system cyrillic-alternativnyj)
435                    (coding-priority cyrillic-alternativnyj)                    (coding-priority cyrillic-alternativnyj)
436                    (input-method . "cyrillic-jcuken")                    (input-method . "russian-typewriter")
437                    (features cyril-util)                    (features cyril-util)
438                    (unibyte-display . cyrillic-alternativnyj)                    (unibyte-display . cyrillic-alternativnyj)
439                    (sample-text . "Russian (,L@caaZXY(B)       ,L7T`PRabRcYbU(B!")                    (sample-text . "Russian (,L@caaZXY(B)       ,L7T`PRabRcYbU(B!")
440                    (documentation . "Support for Cyrillic ALTERNATIVNYJ."))                    (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
441   '("Cyrillic"))   '("Cyrillic"))
442    
443    (set-language-info-alist
444     "Windows-1251" `((coding-system windows-1251)
445                      (coding-priority windows-1251)
446                      (nonascii-translation
447                       . ,(get 'decode-windows-1252 'translation-table))
448                      (input-method . "russian-typewriter") ; fixme?
449                      (features code-pages)
450                      (documentation . "Support for windows-1251 character set."))
451     '("Cyrillic"))
452    
453    (set-language-info-alist
454     "Tajik" `((coding-system cyrillic-koi8-t)
455               (coding-priority cyrillic-koi8-t)
456               (nonascii-translation
457                . ,(get 'decode-koi8-t 'translation-table))
458               (input-method . "russian-typewriter") ; fixme?
459               (features code-pages)
460               (documentation . "Support for Tajik using KOI8-T."))
461     '("Cyrillic"))
462    
463    (set-language-info-alist
464     "Bulgarian" `((coding-system windows-1251)
465                      (coding-priority windows-1251)
466                   (nonascii-translation
467                    . ,(get 'decode-windows-1251 'translation-table))
468                   (input-method . "bulgarian-bds")
469                      (features code-pages)
470                   (documentation
471                    . "Support for Bulgarian with windows-1251 character set.")
472                   (tutorial . "TUTORIAL.bg"))
473     '("Cyrillic"))
474    
475    (set-language-info-alist
476     "Belarusian" `((coding-system windows-1251)
477                    (coding-priority windows-1251)
478                    (nonascii-translation
479                     . ,(get 'decode-windows-1251 'translation-table))
480                    (input-method . "belarusian")
481                    (features code-pages)
482                    (documentation
483                     . "Support for Belarusian with windows-1251 character set.
484    \(The name Belarusian replaced Byelorussian in the early 1990s.)"))
485     '("Cyrillic"))
486    
487  (provide 'cyrillic)  (provide 'cyrillic)
488    
489  ;;; cyrillic.el ends here  ;;; cyrillic.el ends here

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.31.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26