*** empty log message ***
[elisp/tamago.git] / egg-x0213.el
1 ;;; jisx0213.el --- Charset Definition for JIS X 0213
2
3 ;; Copyright (C) 1999,2000 PFU LIMITED
4
5 ;; Author: KATAYAMA Yoshio <kate@pfu.co.jp>
6
7 ;; Maintainer: TOMURA Satoru <tomura@etl.go.jp>
8
9 ;; Keywords: mule, multilingual, input method
10
11 ;; This file is part of EGG.
12
13 ;; EGG is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; EGG is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Commentary:
29
30 ;; This module defines JIS X 0213 character sets if these character
31 ;; sets are not defined.  This module also defines fixed-euc-jisx0213
32 ;; coding systems if these coding systems are not defined and can be
33 ;; defined.
34
35 ;;; Code:
36
37 (if (not (charsetp 'japanese-jisx0213-1))
38     (define-charset 151 'japanese-jisx0213-1
39       [2 94 2 0 ?O 0 "JISX0213-1" "JISX0213-1" "JISX0213-1 (Japanese)"]))
40
41 (if (not (charsetp 'japanese-jisx0213-2))
42     (define-charset 254 'japanese-jisx0213-2
43       [2 94 2 0 ?P 0 "JISX0213-2" "JISX0213-2" "JISX0213-2 (Japanese)"]))
44
45 ;; Mule-UCS is required to adopt fixed-euc-jisx0213.
46 (or 
47  noninteractive ;; unnecessary in non-interactive mode.
48  (unless (or (require 'jisx0213)
49              (get 'jisx0213-to-jisx0208/0212 'translation-table))
50    (message "Mule-UCS not installed."))
51  (coding-system-p 'fixed-euc-jisx0213)
52  (progn
53
54    (define-ccl-program ccl-decode-fixed-euc-jisx0213
55      `(2
56        ((r3 = ,(charset-id 'katakana-jisx0201))
57         (loop ;;      ascii kana 212 208
58          (read r0) ;; r0 -   0    0    h   h
59          (read r1) ;; r1 -   l    h    l   h
60          (if (r0 < ?\x80)
61              ((if (r1 < ?\x80)
62                   (write-repeat r1))
63               (write r3)
64               (write-repeat r1))
65            ((r0 &= 127)
66             (r0 <<= 7)
67             (if (r1 > ?\x80)
68                 ((r1 &= 127)
69                  (r2 = ,(charset-id 'japanese-jisx0213-1)))
70               (r2 = ,(charset-id 'japanese-jisx0213-2)))
71             (r0 += r1)
72             (translate-character jisx0213-to-jisx0208/0212 r2 r0)
73             (write-multibyte-character r2 r0)
74             (repeat)
75             ))))))
76
77    (define-ccl-program ccl-encode-fixed-euc-jisx0213
78      `(2
79        ((loop
80          (read-multibyte-character r0 r1)
81          (r6 = (r0 == ,(charset-id 'ascii))) ;G0
82          (r6 |= (r0 == ,(charset-id 'latin-jisx0201)))
83          (if r6
84              ((write 0)
85               (write-repeat r1)))
86          (r6 = (r0 == ,(charset-id 'japanese-jisx0208)))
87          (r6 |= (r0 == ,(charset-id 'japanese-jisx0208-1978)))
88          (r6 |= (r0 == ,(charset-id 'japanese-jisx0213-1)))
89          (if r6                         ;G1
90              ((r2 = (r1 >> 7))
91               (write (r2 | ?\x80))
92               (write ((r1 & ?\x7f) | ?\x80))
93               (repeat)))
94          (if (r0 == ,(charset-id 'katakana-jisx0201)) ;G2
95              ((write 0)
96               (write (r1 | ?\x80))
97               (repeat)))
98          (r6 = (r0 == ,(charset-id 'japanese-jisx0212))) ;G3
99          (r6 |= (r0 == ,(charset-id 'japanese-jisx0213-2)))
100          (if r6
101              ((r2 = (r1 >> 7))
102               (write (r2 | ?\x80))
103               (write (r1 & ?\x7f))
104               (repeat)))
105          (repeat)))))
106
107    (make-coding-system 
108     'fixed-euc-jisx0213 4 ?W "Coding System for fixed EUC Japanese"
109     (cons ccl-decode-fixed-euc-jisx0213 ccl-encode-fixed-euc-jisx0213))))
110
111 (provide 'egg-x0213)