1 ;;; x0213-sjis.el --- Shift-JIS encoder and decoder for JIS X 0213.
3 ;; Copyright (C) 2000 Miyashita Hisashi
5 ;; Keywords: mule, multilingual,
6 ;; character set, coding-system, JIS X 0213
9 ;; This file is part of Mule-UCS
11 ;; Mule-UCS is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; Mule-UCS is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
29 ;;; In JIS X 0213 plain 2, mapping between row and SJIS S1.
62 (mucs-type-register-serialization
65 '(quote (((write-multibyte-character r1 r0))))
66 '(quote (((read-multibyte-character r1 r0)))))
68 (defun mucs-ccl-write-char-2-dos ()
70 ((if ,(mucs-ccl-check-internal-state 'previous-cr-p)
72 ,(mucs-ccl-set-internal-state 'previous-cr-p t)))
74 (if (,(mucs-ccl-check-internal-state 'previous-cr-p) & r4)
76 ,@(mucs-ccl-set-internal-state 'previous-cr-p nil)
77 (write-multibyte-character r1 r0)))))
79 (mucs-type-register-serialization
82 (quote `(,(mucs-ccl-write-char-2-dos)))
85 (defvar jisx0213-shift-jis-plain-2-encode-table
86 (let ((result (make-vector 128 0))
87 (alist '((1 . ?\xF0) (3 . ?\xF1) (4 . ?\xF1) (5 . ?\xF2) (8 . ?\xF0)
88 (12 . ?\xF2) (13 . ?\xF3) (14 . ?\xF3) (15 . ?\xF4)
89 (78 . ?\xF4) (79 . ?\xF5) (80 . ?\xF5) (81 . ?\xF6)
90 (82 . ?\xF6) (83 . ?\xF7) (84 . ?\xF7) (85 . ?\xF8)
91 (86 . ?\xF8) (87 . ?\xF9) (88 . ?\xF9) (89 . ?\xFA)
92 (90 . ?\xFA) (91 . ?\xFB) (92 . ?\xFB) (93 . ?\xFC)
96 (setq elem (car alist)
99 (aset result i (cdr elem)))
102 (defun mucs-ccl-char-2-write-shift-jisx0213-char (dosp)
103 `((if (r1 == ,(charset-id 'ascii))
109 ((if (r1 == ,(charset-id 'japanese-jisx0213-1))
112 (r0 = (r1 en-sjis r0))
114 ((if (r1 == ,(charset-id 'japanese-jisx0213-2))
117 (r0 = (r1 en-sjis r0))
118 (r0 = r1 ,jisx0213-shift-jis-plain-2-encode-table)
120 ;;; katakana-jisx0201
121 ((write (r0 + ,(- ?\xA1 33)))))))))))
123 (defun mucs-ccl-char-2-read-shift-jisx0213-char ()
125 (read-if (r0 >= ?\x81)
126 ((r1 = (r0 <= ?\x9F))
127 (r1 |= (r0 >= ?\xE0))
131 ;; JIS X 0213 plain 2
132 ((r4 = (r0 de-sjis r1))
136 jisx0213-shift-jis-plain-2-even-decode-map))
138 jisx0213-shift-jis-plain-2-odd-decode-map)))
139 (r0 <<= 7) (r0 += r4)
140 (r1 = ,(charset-id 'japanese-jisx0213-2)))
141 ;; JIS X 0213 plain 1.
142 ((r1 = (r0 de-sjis r1))
143 (r0 = (r1 << 7)) (r0 += r7)
144 (r1 = ,(charset-id 'japanese-jisx0213-1)))))
145 ((r1 = ,(charset-id 'katakana-jisx0201))
146 (r0 -= ,(- ?\xA1 33))))))))
148 (mucs-type-register-serialization
151 (quote `(,(mucs-ccl-char-2-write-shift-jisx0213-char nil)))
152 (quote `(,(mucs-ccl-char-2-read-shift-jisx0213-char))))
154 (mucs-type-register-serialization
157 (quote `(,(mucs-ccl-char-2-write-shift-jisx0213-char t)))
160 (provide 'x0213-sjis)