Initial Commit
[packages] / mule-packages / mule-ucs / lisp / big5conv / big5c-cns.el
1 ;;; -*- coding: iso-2022-7bit  -*-
2 ;;; big5c-cns.el --- Definition module for conversion of BIG5
3 ;;;                  directly mapped to mainly CNS charsets.
4
5 ;; Copyright (C) 1999 Miyashita Hisashi
6
7 ;; Keywords: mule, multilingual, 
8 ;;           MULE-UCS, Big5, CNS, Traditional Chinese
9
10 ;; This file is part of MULE-UCS
11
12 ;; MULE-UCS is free software; you can redistribute it and/or modify
13 ;; it 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 ;; MULE-UCS is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with this program; see the file COPYING.  If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
26
27 (defvar big5-conv-cns-coding-system-alist
28   '((safe-charsets .
29                    (ascii
30                     chinese-cns11643-1
31                     chinese-cns11643-2
32 ;;                  japanese-jisx0208
33 ;;                  chinese-gb2312
34                     ))
35     (mime-charset . cn-big5))
36   "An alist for big5-conv coding systems.")
37
38 (eval-when-compile
39   (require 'mucs)
40   (mucs-require-supplement 'big5conv 'big5c-cns)
41
42   (tae-declare-translation
43    'big5-conv-cns-translation
44    `(| ,big5conv-ascii-assoc
45        ,big5conv-emacs-char-1-vs-big5-assoc))
46
47   (tae-declare-translation
48    'big5-conv-cns-mac-translation
49    `(| (assoc (char-1 . big5)
50               ((?\x0A . ?\x0D)))
51        big5-conv-cns-translation))
52
53   (defun big5-conv-cns-decode-template (tr read write)
54     (mucs-ccl-stream-form
55      (mucs-ccl-read 'big5 read)
56      (tae-compile tr t)
57      (mucs-ccl-write write)))
58
59   (defun big5-conv-cns-encode-template (tr read write)
60     (mucs-ccl-stream-form
61      (mucs-ccl-read 'char-1 read)
62      (tae-compile tr nil)
63      (mucs-ccl-write write)))
64
65   )
66
67 ;;
68 ;; coding system definitions.
69 ;;
70
71 (mucs-define-package
72  big5c-cns
73
74 ;;
75 ;; conversion definition.
76 ;;
77
78 ;;; For stream conversion.
79
80 ;; for big5-conv-unix
81  (mucs-define-conversion
82   big5-conv-cns-unix-stream-encoder
83   stream
84   (big5conv-encode-buffer-magnification
85    ((big5-conv-cns-encode-template
86      'big5-conv-cns-translation 'emacs-mule 'big5-be-2-octet))))
87  (mucs-define-conversion
88   big5-conv-cns-unix-stream-decoder
89   stream
90   (big5conv-decode-buffer-magnification
91    ((big5-conv-cns-decode-template
92      'big5-conv-cns-translation 'big5-be-2-octet 'emacs-mule))))
93
94 ;; for big5-conv-dos
95  (mucs-define-conversion
96   big5-conv-cns-dos-stream-encoder
97   stream
98   (big5conv-encode-buffer-magnification
99    ((big5-conv-cns-encode-template
100      'big5-conv-cns-translation 'emacs-mule 'big5-be-2-octet-dos))))
101  (mucs-define-conversion
102   big5-conv-cns-dos-stream-decoder
103   stream
104   (big5conv-decode-buffer-magnification
105    ((big5-conv-cns-decode-template
106      'big5-conv-cns-translation 'big5-be-2-octet 'emacs-mule-dos))))
107
108 ;; for big5-conv-mac
109  (mucs-define-conversion
110   big5-conv-cns-mac-stream-encoder
111   stream
112   (big5conv-encode-buffer-magnification
113    ((big5-conv-cns-encode-template
114      'big5-conv-cns-mac-translation 'emacs-mule 'big5-be-2-octet))))
115  (mucs-define-conversion
116   big5-conv-cns-mac-stream-decoder
117   stream
118   (big5conv-decode-buffer-magnification
119    ((big5-conv-cns-decode-template
120      'big5-conv-cns-mac-translation 'big5-be-2-octet 'emacs-mule))))
121
122 ;;
123 ;; coding-system-definition.
124 ;;
125  (mucs-define-coding-system
126   'big5-conv-unix ?B
127   "Big5 coding system which convert Big5 characters to mainly CNS ones."
128   'big5-conv-cns-unix-stream-decoder
129   'big5-conv-cns-unix-stream-encoder
130   big5-conv-cns-coding-system-alist
131   'unix)
132
133  (mucs-define-coding-system
134   'big5-conv-dos ?B
135   "Big5 coding system which convert Big5 characters to mainly CNS ones."
136   'big5-conv-cns-dos-stream-decoder
137   'big5-conv-cns-dos-stream-encoder
138   big5-conv-cns-coding-system-alist
139   'dos)
140
141  (mucs-define-coding-system
142   'big5-conv-mac ?B
143   "Big5 coding system which convert Big5 characters to mainly CNS ones."
144   'big5-conv-cns-mac-stream-decoder
145   'big5-conv-cns-mac-stream-encoder
146   big5-conv-cns-coding-system-alist
147   'mac)
148
149  (mucs-define-coding-system
150   'big5-conv ?B
151   "Big5 coding system which convert Big5 characters to mainly CNS ones."
152   'big5-conv-cns-unix-stream-decoder
153   'big5-conv-cns-unix-stream-encoder
154   big5-conv-cns-coding-system-alist
155   '[big5-conv-unix big5-conv-dos big5-conv-mac])
156
157  (mapcar
158   (lambda (x)
159     (coding-system-put x 'alias-coding-systems '(big5-conv)))
160   '(big5-conv big5-conv-dos big5-conv-unix big5-conv-mac))
161
162 ) ;; big5c-cns package definition ends here
163
164 ;; set up coding category
165 (if (boundp 'coding-category-big5)
166     (setq coding-category-big5 'big5-conv))
167
168 (provide 'big5c-cns)