428
+ − 1 ;;; cyrillic.el --- Support for Cyrillic -*- coding: iso-2022-7bit; -*-
+ − 2
+ − 3 ;; Copyright (C) 1995,1999 Electrotechnical Laboratory, JAPAN.
+ − 4 ;; Licensed to the Free Software Foundation.
+ − 5 ;; Copyright (C) 1997 MORIOKA Tomohiko
788
+ − 6 ;; Copyright (C) 2001, 2002 Ben Wing.
428
+ − 7
+ − 8 ;; Keywords: multilingual, Cyrillic
+ − 9
+ − 10 ;; This file is part of XEmacs.
+ − 11
+ − 12 ;; XEmacs is free software; you can redistribute it and/or modify it
+ − 13 ;; under the terms of the GNU General Public License as published by
+ − 14 ;; the Free Software Foundation; either version 2, or (at your option)
+ − 15 ;; any later version.
+ − 16
+ − 17 ;; XEmacs is distributed in the hope that it will be useful, but
+ − 18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
+ − 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ − 20 ;; General Public License for more details.
+ − 21
+ − 22 ;; You should have received a copy of the GNU General Public License
+ − 23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
+ − 24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ − 25 ;; 02111-1307, USA.
+ − 26
+ − 27 ;;; Commentary:
+ − 28
771
+ − 29 ;; The character set ISO8859-5 is supported. KOI-8 and ALTERNATIVNYJ are
+ − 30 ;; converted to ISO8859-5 internally.
+ − 31
+ − 32 ;; Windows-1251 support deleted because XEmacs has automatic support.
428
+ − 33
+ − 34 ;;; Code:
+ − 35
444
+ − 36 ;; Cyrillic syntax
428
+ − 37 (modify-syntax-entry 'cyrillic-iso8859-5 "w")
+ − 38 (modify-syntax-entry ?,L-(B ".")
+ − 39 (modify-syntax-entry ?,Lp(B ".")
+ − 40 (modify-syntax-entry ?,L}(B ".")
+ − 41
+ − 42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ − 43 ;;; CYRILLIC
+ − 44 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+ − 45
444
+ − 46 ;; ISO-8859-5
428
+ − 47
778
+ − 48 ; (make-charset 'cyrillic-iso8859-5
+ − 49 ; "Right-Hand Part of Latin/Cyrillic Alphabet (ISO/IEC 8859-5): ISO-IR-144"
+ − 50 ; '(dimension
+ − 51 ; 1
+ − 52 ; registry "ISO8859-5"
+ − 53 ; chars 96
+ − 54 ; columns 1
+ − 55 ; direction l2r
+ − 56 ; final ?L
+ − 57 ; graphic 1
+ − 58 ; short-name "RHP of ISO8859/5"
+ − 59 ; long-name "RHP of Cyrillic (ISO 8859-5): ISO-IR-144"
+ − 60 ; ))
+ − 61
428
+ − 62 (make-coding-system
+ − 63 'iso-8859-5 'iso2022
771
+ − 64 "ISO-8859-5 (Cyrillic)"
428
+ − 65 '(charset-g0 ascii
+ − 66 charset-g1 cyrillic-iso8859-5
+ − 67 charset-g2 t
+ − 68 charset-g3 t
+ − 69 mnemonic "ISO8/Cyr"
+ − 70 ))
+ − 71
+ − 72 (set-language-info-alist
+ − 73 "Cyrillic-ISO" '((charset cyrillic-iso8859-5)
+ − 74 (tutorial . "TUTORIAL.ru")
+ − 75 (coding-system iso-8859-5)
+ − 76 (coding-priority iso-8859-5)
+ − 77 (input-method . "cyrillic-yawerty")
+ − 78 (features cyril-util)
+ − 79 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
+ − 80 (documentation . "Support for Cyrillic ISO-8859-5."))
+ − 81 '("Cyrillic"))
+ − 82
444
+ − 83 ;; KOI-8
428
+ − 84
+ − 85 (eval-and-compile
+ − 86
+ − 87 (defvar cyrillic-koi8-r-decode-table
+ − 88 [
+ − 89 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ − 90 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ − 91 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
+ − 92 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
+ − 93 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
+ − 94 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
+ − 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
+ − 96 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
+ − 97 ?$B(!(B ?$B("(B ?$B(#(B ?$B($(B ?$B(&(B ?$B(%(B ?$B('(B ?$B()(B ?$B(((B ?$B(*(B ?$B(+(B 32 ?$(G#'(B ?$(G#+(B ?$(G#/(B 32
+ − 98 32 ?$(C"F(B 32 32 ?$B"#(B 32 ?$B"e(B ?$A!V(B ?$A!\(B ?$A!](B ?,L (B 32 ?,A0(B ?,A2(B ?,A7(B ?,Aw(B
+ − 99 ?$(G#D(B 32 32 ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 ?$(G#E(B
+ − 100 32 32 ?$(G#G(B ?,L!(B 32 32 32 32 32 32 32 32 ?$(G#F(B 32 32 ?,A)(B
+ − 101 ?,Ln(B ?,LP(B ?,LQ(B ?,Lf(B ?,LT(B ?,LU(B ?,Ld(B ?,LS(B ?,Le(B ?,LX(B ?,LY(B ?,LZ(B ?,L[(B ?,L\(B ?,L](B ?,L^(B
+ − 102 ?,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
+ − 103 ?,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
+ − 104 ?,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 ]
+ − 105 "Cyrillic KOI8-R decoding table.")
+ − 106
+ − 107 (defvar cyrillic-koi8-r-encode-table
+ − 108 (let ((table (make-vector 256 32))
+ − 109 (i 0))
+ − 110 (while (< i 256)
+ − 111 (let* ((ch (aref cyrillic-koi8-r-decode-table i))
+ − 112 (split (split-char ch)))
+ − 113 (cond ((eq (car split) 'cyrillic-iso8859-5)
+ − 114 (aset table (logior (nth 1 split) 128) i)
+ − 115 )
+ − 116 ((eq ch 32))
+ − 117 ((eq (car split) 'ascii)
+ − 118 (aset table ch i)
+ − 119 )))
+ − 120 (setq i (1+ i)))
+ − 121 table)
+ − 122 "Cyrillic KOI8-R encoding table.")
+ − 123
+ − 124 )
+ − 125
+ − 126 (define-ccl-program ccl-decode-koi8
+ − 127 `(3
+ − 128 ((read r0)
+ − 129 (loop
+ − 130 (write-read-repeat r0 ,cyrillic-koi8-r-decode-table))))
+ − 131 "CCL program to decode KOI8.")
+ − 132
+ − 133 (define-ccl-program ccl-encode-koi8
+ − 134 `(1
+ − 135 ((read r0)
+ − 136 (loop
+ − 137 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
+ − 138 (write-read-repeat r0)
+ − 139 ((read r0)
+ − 140 (write-read-repeat r0 , cyrillic-koi8-r-encode-table))))))
+ − 141 "CCL program to encode KOI8.")
+ − 142
+ − 143 ;; (define-coding-system-alias 'koi8-r 'cyrillic-koi8)
+ − 144 ;; (define-coding-system-alias 'koi8 'cyrillic-koi8)
+ − 145
+ − 146 (make-coding-system
+ − 147 'koi8-r 'ccl
771
+ − 148 "KOI8-R (Cyrillic)"
444
+ − 149 '(decode ccl-decode-koi8
+ − 150 encode ccl-encode-koi8
428
+ − 151 mnemonic "KOI8"))
+ − 152
444
+ − 153 ;; `iso-8-1' is not correct, but XEmacs doesn't have a `ccl' category
428
+ − 154 (coding-system-put 'koi8-r 'category 'iso-8-1)
+ − 155
+ − 156 ;; (define-ccl-program ccl-encode-koi8-font
+ − 157 ;; `(0
+ − 158 ;; ((r1 |= 128)
+ − 159 ;; (r1 = r1 ,cyrillic-koi8-r-encode-table)))
+ − 160 ;; "CCL program to encode Cyrillic chars to KOI font.")
+ − 161
+ − 162 ;; (setq font-ccl-encoder-alist
+ − 163 ;; (cons (cons "koi8" ccl-encode-koi8-font) font-ccl-encoder-alist))
+ − 164
788
+ − 165 (defvar cyrillic-koi8-r-to-external-code-table
+ − 166 (let ((table (make-char-table 'generic))
+ − 167 (i 0)
+ − 168 (len (length cyrillic-koi8-r-decode-table)))
+ − 169 (while (< i len)
+ − 170 (let ((ch (aref cyrillic-koi8-r-decode-table i)))
+ − 171 (if (characterp ch)
+ − 172 (put-char-table ch i table)))
+ − 173 (incf i)))
+ − 174 "Table to convert from characters to their Koi8-R code.")
428
+ − 175
+ − 176 (set-language-info-alist
+ − 177 "Cyrillic-KOI8" '((charset cyrillic-iso8859-5)
+ − 178 (coding-system koi8-r)
+ − 179 (coding-priority koi8-r)
+ − 180 (input-method . "cyrillic-yawerty")
+ − 181 (features cyril-util)
771
+ − 182 (locale "ru")
+ − 183 (mswindows-locale . "RUSSIAN")
428
+ − 184 (tutorial . "TUTORIAL.ru")
+ − 185 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
+ − 186 (documentation . "Support for Cyrillic KOI8-R."))
+ − 187 '("Cyrillic"))
+ − 188
771
+ − 189 ;;; WINDOWS-1251 deleted; we support it automatically in XEmacs
444
+ − 190
+ − 191 ;;; ALTERNATIVNYJ
428
+ − 192
+ − 193 (eval-and-compile
+ − 194
+ − 195 (defvar cyrillic-alternativnyj-decode-table
+ − 196 [
+ − 197 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
+ − 198 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ − 199 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
+ − 200 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
+ − 201 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
+ − 202 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
+ − 203 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
+ − 204 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
+ − 205 ?,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
+ − 206 ?,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
+ − 207 ?,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
+ − 208 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
+ − 209 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
+ − 210 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
+ − 211 ?,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
+ − 212 ?,L!(B ?,Lq(B 32 32 32 32 32 32 32 32 32 32 32 32 32 ?,Lp(B]
+ − 213 "Cyrillic ALTERNATIVNYJ decoding table.")
+ − 214
+ − 215 (defvar cyrillic-alternativnyj-encode-table
+ − 216 (let ((table (make-vector 256 32))
+ − 217 (i 0))
+ − 218 (while (< i 256)
+ − 219 (let* ((ch (aref cyrillic-alternativnyj-decode-table i))
+ − 220 (split (split-char ch)))
+ − 221 (if (eq (car split) 'cyrillic-iso8859-5)
+ − 222 (aset table (logior (nth 1 split) 128) i)
+ − 223 (if (/= ch 32)
+ − 224 (aset table ch i))))
+ − 225 (setq i (1+ i)))
+ − 226 table)
+ − 227 "Cyrillic ALTERNATIVNYJ encoding table.")
+ − 228
+ − 229 )
+ − 230
+ − 231
+ − 232 (define-ccl-program ccl-decode-alternativnyj
+ − 233 `(3
+ − 234 ((read r0)
+ − 235 (loop
+ − 236 (write-read-repeat r0 ,cyrillic-alternativnyj-decode-table))))
+ − 237 "CCL program to decode Alternativnyj.")
+ − 238
+ − 239 (define-ccl-program ccl-encode-alternativnyj
+ − 240 `(1
+ − 241 ((read r0)
+ − 242 (loop
+ − 243 (if (r0 != ,(charset-id 'cyrillic-iso8859-5))
+ − 244 (write-read-repeat r0)
+ − 245 ((read r0)
+ − 246 (write-read-repeat r0 ,cyrillic-alternativnyj-encode-table))))))
+ − 247 "CCL program to encode Alternativnyj.")
+ − 248
+ − 249 ;; (define-coding-system-alias 'alternativnyj 'cyrillic-alternativnyj)
+ − 250
+ − 251 (make-coding-system
+ − 252 'alternativnyj 'ccl
771
+ − 253 "Alternativnyj (Cyrillic)"
444
+ − 254 '(decode ccl-decode-alternativnyj
+ − 255 encode ccl-encode-alternativnyj
428
+ − 256 mnemonic "Cy.Alt"))
+ − 257
444
+ − 258 ;; `iso-8-1' is not correct, but XEmacs doesn't have `ccl' category
428
+ − 259 (coding-system-put 'alternativnyj 'category 'iso-8-1)
+ − 260
+ − 261 ;; (define-ccl-program ccl-encode-alternativnyj-font
+ − 262 ;; '(0
+ − 263 ;; ((r1 |= 128)
+ − 264 ;; (r1 = r1 ,cyrillic-alternativnyj-encode-table)))
+ − 265 ;; "CCL program to encode Cyrillic chars to Alternativnyj font.")
+ − 266
+ − 267 ;; (setq font-ccl-encoder-alist
+ − 268 ;; (cons (cons "alternativnyj" ccl-encode-alternativnyj-font)
+ − 269 ;; font-ccl-encoder-alist))
+ − 270
788
+ − 271 (defvar cyrillic-alternativnyj-to-external-code-table
+ − 272 (let ((table (make-char-table 'generic))
+ − 273 (i 0)
+ − 274 (len (length cyrillic-alternativnyj-decode-table)))
+ − 275 (while (< i len)
+ − 276 (let ((ch (aref cyrillic-alternativnyj-decode-table i)))
+ − 277 (if (characterp ch)
+ − 278 (put-char-table ch i table)))
+ − 279 (incf i)))
+ − 280 "Table to convert from characters to their Alternativnyj code.")
428
+ − 281
+ − 282 (set-language-info-alist
+ − 283 "Cyrillic-ALT" '((charset cyrillic-iso8859-5)
+ − 284 (coding-system alternativnyj)
+ − 285 (coding-priority alternativnyj)
+ − 286 (input-method . "cyrillic-yawerty")
+ − 287 (features cyril-util)
+ − 288 (tutorial . "TUTORIAL.ru")
+ − 289 (sample-text . "Russian (,L@caaZXY(B) ,L7T`PRabRcYbU(B!")
+ − 290 (documentation . "Support for Cyrillic ALTERNATIVNYJ."))
+ − 291 '("Cyrillic"))
+ − 292
+ − 293 ;;; cyrillic.el ends here