comparison lisp/mule/cyrillic.el @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents 3ecd8885ac67
children 943eaba38521
comparison
equal deleted inserted replaced
443:a8296e22da4e 444:576fb035e263
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 ;; 02111-1307, USA. 24 ;; 02111-1307, USA.
25 25
26 ;;; Commentary: 26 ;;; Commentary:
27 27
28 ;; The character set ISO8859-5 is supported. KOI-8 and ALTERNATIVNYJ 28 ;; The character set ISO8859-5 is supported.
29 ;; are converted to ISO8859-5 internally. 29 ;; KOI-8, Windows-1251, and ALTERNATIVNYJ are converted to ISO8859-5
30 ;; internally.
30 31
31 ;;; Code: 32 ;;; Code:
32 33
33 ;; For syntax of Cyrillic 34 ;; Cyrillic syntax
34 (modify-syntax-entry 'cyrillic-iso8859-5 "w") 35 (modify-syntax-entry 'cyrillic-iso8859-5 "w")
35 (modify-syntax-entry ?,L-(B ".") 36 (modify-syntax-entry ?,L-(B ".")
36 (modify-syntax-entry ?,Lp(B ".") 37 (modify-syntax-entry ?,Lp(B ".")
37 (modify-syntax-entry ?,L}(B ".") 38 (modify-syntax-entry ?,L}(B ".")
38 39
39 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 40 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40 ;;; CYRILLIC 41 ;;; CYRILLIC
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
42 43
43 ;; ISO-8859-5 staff 44 ;; ISO-8859-5
44
45 ;; (make-coding-system
46 ;; 'cyrillic-iso-8bit 2 ?5
47 ;; "ISO 2022 based 8-bit encoding for Cyrillic script (MIME:ISO-8859-5)"
48 ;; '(ascii cyrillic-iso8859-5 nil nil
49 ;; nil nil nil nil nil nil nil)
50 ;; '((safe-charsets ascii cyrillic-iso8859-5)
51 ;; (mime-charset . iso-8859-5)))
52
53 ;; (define-coding-system-alias 'iso-8859-5 'cyrillic-iso-8bit)
54 45
55 (make-coding-system 46 (make-coding-system
56 'iso-8859-5 'iso2022 47 'iso-8859-5 'iso2022
57 "MIME ISO-8859-5" 48 "ISO-8859-5 (ISO 2022 based 8-bit encoding for Cyrillic script)"
58 '(charset-g0 ascii 49 '(charset-g0 ascii
59 charset-g1 cyrillic-iso8859-5 50 charset-g1 cyrillic-iso8859-5
60 charset-g2 t 51 charset-g2 t
61 charset-g3 t 52 charset-g3 t
62 mnemonic "ISO8/Cyr" 53 mnemonic "ISO8/Cyr"
71 (features cyril-util) 62 (features cyril-util)
72 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!") 63 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
73 (documentation . "Support for Cyrillic ISO-8859-5.")) 64 (documentation . "Support for Cyrillic ISO-8859-5."))
74 '("Cyrillic")) 65 '("Cyrillic"))
75 66
76 ;; KOI-8 staff 67 ;; KOI-8
77 68
78 (eval-and-compile 69 (eval-and-compile
79 70
80 (defvar cyrillic-koi8-r-decode-table 71 (defvar cyrillic-koi8-r-decode-table
81 [ 72 [
131 (write-read-repeat r0) 122 (write-read-repeat r0)
132 ((read r0) 123 ((read r0)
133 (write-read-repeat r0 , cyrillic-koi8-r-encode-table)))))) 124 (write-read-repeat r0 , cyrillic-koi8-r-encode-table))))))
134 "CCL program to encode KOI8.") 125 "CCL program to encode KOI8.")
135 126
136 ;; (make-coding-system
137 ;; 'cyrillic-koi8 4
138 ;; ;; We used to use ?K. It is true that ?K is more strictly correct,
139 ;; ;; but it is also used for Korean.
140 ;; ;; So people who use koi8 for languages other than Russian
141 ;; ;; will have to forgive us.
142 ;; ?R "KOI8 8-bit encoding for Cyrillic (MIME: KOI8-R)"
143 ;; '(ccl-decode-koi8 . ccl-encode-koi8)
144 ;; '((safe-charsets ascii cyrillic-iso8859-5)
145 ;; (mime-charset . koi8-r)
146 ;; (valid-codes (0 . 127) 163 179 (192 . 255))
147 ;; (charset-origin-alist (cyrillic-iso8859-5 "KOI8-R"
148 ;; cyrillic-encode-koi8-r-char))))
149
150 ;; (define-coding-system-alias 'koi8-r 'cyrillic-koi8) 127 ;; (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
151 ;; (define-coding-system-alias 'koi8 'cyrillic-koi8) 128 ;; (define-coding-system-alias 'koi8 'cyrillic-koi8)
152 129
153 (make-coding-system 130 (make-coding-system
154 'koi8-r 'ccl 131 'koi8-r 'ccl
155 "Coding-system used for KOI8-R." 132 "KOI8-R 8-bit encoding for Cyrillic."
156 `(decode ,ccl-decode-koi8 133 '(decode ccl-decode-koi8
157 encode ,ccl-encode-koi8 134 encode ccl-encode-koi8
158 mnemonic "KOI8")) 135 mnemonic "KOI8"))
159 136
160 ;; it is not correct, but XEmacs doesn't have `ccl' category... 137 ;; `iso-8-1' is not correct, but XEmacs doesn't have a `ccl' category
161 (coding-system-put 'koi8-r 'category 'iso-8-1) 138 (coding-system-put 'koi8-r 'category 'iso-8-1)
162 139
163 ;; (define-ccl-program ccl-encode-koi8-font 140 ;; (define-ccl-program ccl-encode-koi8-font
164 ;; `(0 141 ;; `(0
165 ;; ((r1 |= 128) 142 ;; ((r1 |= 128)
182 (tutorial . "TUTORIAL.ru") 159 (tutorial . "TUTORIAL.ru")
183 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!") 160 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
184 (documentation . "Support for Cyrillic KOI8-R.")) 161 (documentation . "Support for Cyrillic KOI8-R."))
185 '("Cyrillic")) 162 '("Cyrillic"))
186 163
187 ;;; ALTERNATIVNYJ staff 164 ;;; WINDOWS-1251
165
166 (eval-and-compile
167
168 (defvar cyrillic-windows-1251-decode-table
169 [
170 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
171 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
172 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
173 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
174 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
175 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
176 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
177 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
178 ?,L"(B ?,L#(B 32 ?,Ls(B 32 32 32 32 32 32 ?,L)(B 32 ?,L*(B ?,L,(B ?,L+(B ?,L/(B ;"
179 ?,Lr(B 32 32 32 32 32 32 32 32 32 ?,Ly(B 32 ?,Lz(B ?,L|(B ?,L{(B ?,L(B
180 ?,L (B ?,L.(B ?,L~(B ?,L((B ?,A$(B 32 ?,A&(B ?,L}(B ?,L!(B ?,A)(B ?,L$(B ?,A+(B ?,A,(B ?,L-(B ?,A.(B ?,L'(B
181 ?,A0(B ?,A1(B ?,L&(B ?,Lv(B 32 ?,A5(B ?,A6(B ?,A7(B ?,Lq(B ?,Lp(B ?,Lt(B ?,A;(B ?,Lx(B ?,L%(B ?,Lu(B ?,Lw(B
182 ?,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
183 ?,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
184 ?,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
185 ?,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 ]
186 "Cyrillic Windows-1251 decoding table.")
187
188 (defvar cyrillic-windows-1251-encode-table
189 (let ((table (make-vector 256 32))
190 (i 0))
191 (while (< i 256)
192 (let* ((ch (aref cyrillic-windows-1251-decode-table i))
193 (split (split-char ch)))
194 (cond ((eq (car split) 'cyrillic-iso8859-5)
195 (aset table (logior (nth 1 split) 128) i)
196 )
197 ((eq ch 32))
198 ((eq (car split) 'ascii)
199 (aset table ch i)
200 )))
201 (setq i (1+ i)))
202 table)
203 "Cyrillic Windows-1251 encoding table.")
204
205 )
206
207 (define-ccl-program ccl-decode-windows1251
208 `(3
209 ((read r0)
210 (loop
211 (write-read-repeat r0 ,cyrillic-windows-1251-decode-table))))
212 "CCL program to decode Windows-1251.")
213
214 (define-ccl-program ccl-encode-windows1251
215 `(1
216 ((read r0)
217 (loop
218 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
219 (write-read-repeat r0)
220 ((read r0)
221 (write-read-repeat r0 , cyrillic-windows-1251-encode-table))))))
222 "CCL program to encode Windows-1251.")
223
224 (make-coding-system
225 'windows-1251 'ccl
226 "Coding-system used for Windows-1251."
227 '(decode ccl-decode-windows1251
228 encode ccl-encode-windows1251
229 mnemonic "CyrW"))
230
231 ;; `iso-8-1' is not correct, but XEmacs doesn't have a `ccl' category
232 (coding-system-put 'windows-1251 'category 'iso-8-1)
233
234 (set-language-info-alist
235 "Cyrillic-Win" '((charset cyrillic-iso8859-5)
236 (coding-system windows-1251)
237 (coding-priority windows-1251)
238 (input-method . "cyrillic-yawerty")
239 (features cyril-util)
240 (tutorial . "TUTORIAL.ru")
241 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
242 (documentation . "Support for Cyrillic Windows-1251."))
243 '("Cyrillic"))
244
245 ;;; ALTERNATIVNYJ
188 246
189 (eval-and-compile 247 (eval-and-compile
190 248
191 (defvar cyrillic-alternativnyj-decode-table 249 (defvar cyrillic-alternativnyj-decode-table
192 [ 250 [
240 (write-read-repeat r0) 298 (write-read-repeat r0)
241 ((read r0) 299 ((read r0)
242 (write-read-repeat r0 ,cyrillic-alternativnyj-encode-table)))))) 300 (write-read-repeat r0 ,cyrillic-alternativnyj-encode-table))))))
243 "CCL program to encode Alternativnyj.") 301 "CCL program to encode Alternativnyj.")
244 302
245 ;; (make-coding-system
246 ;; 'cyrillic-alternativnyj 4 ?A
247 ;; "ALTERNATIVNYJ 8-bit encoding for Cyrillic"
248 ;; '(ccl-decode-alternativnyj . ccl-encode-alternativnyj)
249 ;; '((safe-charsets ascii cyrillic-iso8859-5)
250 ;; (valid-codes (0 . 175) (224 . 241) 255)
251 ;; (charset-origin-alist (cyrillic-iso8859-5 "ALTERNATIVNYJ"
252 ;; cyrillic-encode-koi8-r-char))))
253
254
255 ;; (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj) 303 ;; (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
256 304
257 (make-coding-system 305 (make-coding-system
258 'alternativnyj 'ccl 306 'alternativnyj 'ccl
259 "Coding-system used for Alternativnyj" 307 "Coding-system used for Alternativnyj"
260 `(decode ,ccl-decode-alternativnyj 308 '(decode ccl-decode-alternativnyj
261 encode ,ccl-encode-alternativnyj 309 encode ccl-encode-alternativnyj
262 mnemonic "Cy.Alt")) 310 mnemonic "Cy.Alt"))
263 311
264 ;; it is not correct, but XEmacs doesn't have `ccl' category... 312 ;; `iso-8-1' is not correct, but XEmacs doesn't have `ccl' category
265 (coding-system-put 'alternativnyj 'category 'iso-8-1) 313 (coding-system-put 'alternativnyj 'category 'iso-8-1)
266 314
267 ;; (define-ccl-program ccl-encode-alternativnyj-font 315 ;; (define-ccl-program ccl-encode-alternativnyj-font
268 ;; '(0 316 ;; '(0
269 ;; ((r1 |= 128) 317 ;; ((r1 |= 128)