APEL 7.1.1.
[elisp/apel.git] / emu-x20.el
1 ;;; emu-x20.el --- emu API implementation for XEmacs with mule
2
3 ;; Copyright (C) 1994,1995,1996,1997 MORIOKA Tomohiko
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: emu-x20.el,v 7.69 1998/01/10 18:00:57 morioka Exp $
7 ;; Keywords: emulation, compatibility, Mule, XEmacs
8
9 ;; This file is part of XEmacs.
10
11 ;; XEmacs is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; XEmacs is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 ;; 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;;    This module requires XEmacs 20.3-b5 or later with mule.
29
30 ;;; Code:
31
32 (require 'emu-xemacs)
33 (require 'emu-20)
34
35
36 (and (coding-system-property 'iso-2022-jp 'input-charset-conversion)
37      (copy-coding-system 'iso-2022-7bit 'iso-2022-jp))
38
39     
40 ;;; @ MIME charset
41 ;;;
42
43 (defsubst encode-mime-charset-region (start end charset)
44   "Encode the text between START and END as MIME CHARSET."
45   (let ((cs (mime-charset-to-coding-system charset)))
46     (if cs
47         (encode-coding-region start end cs)
48       )))
49
50 (defsubst decode-mime-charset-region (start end charset)
51   "Decode the text between START and END as MIME CHARSET."
52   (let ((cs (mime-charset-to-coding-system charset)))
53     (if cs
54         (decode-coding-region start end cs)
55       )))
56
57 (defsubst encode-mime-charset-string (string charset)
58   "Encode the STRING as MIME CHARSET."
59   (let ((cs (mime-charset-to-coding-system charset)))
60     (if cs
61         (encode-coding-string string cs)
62       string)))
63
64 (defsubst decode-mime-charset-string (string charset)
65   "Decode the STRING as MIME CHARSET."
66   (let ((cs (mime-charset-to-coding-system charset)))
67     (if cs
68         (decode-coding-string string cs)
69       string)))
70
71
72 (defvar charsets-mime-charset-alist
73   '(((ascii)                                            . us-ascii)
74     ((ascii latin-iso8859-1)                            . iso-8859-1)
75     ((ascii latin-iso8859-2)                            . iso-8859-2)
76     ((ascii latin-iso8859-3)                            . iso-8859-3)
77     ((ascii latin-iso8859-4)                            . iso-8859-4)
78     ((ascii cyrillic-iso8859-5)                         . iso-8859-5)
79 ;;; ((ascii cyrillic-iso8859-5)                         . koi8-r)
80     ((ascii arabic-iso8859-6)                           . iso-8859-6)
81     ((ascii greek-iso8859-7)                            . iso-8859-7)
82     ((ascii hebrew-iso8859-8)                           . iso-8859-8)
83     ((ascii latin-iso8859-9)                            . iso-8859-9)
84     ((ascii latin-jisx0201
85             japanese-jisx0208-1978 japanese-jisx0208)   . iso-2022-jp)
86     ((ascii korean-ksc5601)                             . euc-kr)
87     ((ascii chinese-gb2312)                             . cn-gb-2312)
88     ((ascii chinese-big5-1 chinese-big5-2)              . cn-big5)
89     ((ascii latin-iso8859-1 greek-iso8859-7
90             latin-jisx0201 japanese-jisx0208-1978
91             chinese-gb2312 japanese-jisx0208
92             korean-ksc5601 japanese-jisx0212)           . iso-2022-jp-2)
93     ((ascii latin-iso8859-1 greek-iso8859-7
94             latin-jisx0201 japanese-jisx0208-1978
95             chinese-gb2312 japanese-jisx0208
96             korean-ksc5601 japanese-jisx0212
97             chinese-cns11643-1 chinese-cns11643-2)      . iso-2022-int-1)
98     ((ascii latin-iso8859-1 latin-iso8859-2
99             cyrillic-iso8859-5 greek-iso8859-7
100             latin-jisx0201 japanese-jisx0208-1978
101             chinese-gb2312 japanese-jisx0208
102             korean-ksc5601 japanese-jisx0212
103             chinese-cns11643-1 chinese-cns11643-2
104             chinese-cns11643-3 chinese-cns11643-4
105             chinese-cns11643-5 chinese-cns11643-6
106             chinese-cns11643-7)                         . iso-2022-int-1)
107     ))
108
109 (defun detect-mime-charset-region (start end)
110   "Return MIME charset for region between START and END."
111   (charsets-to-mime-charset (charsets-in-region start end)))
112
113
114 ;;; @ character
115 ;;;
116
117 ;;; @@ Mule emulating aliases
118 ;;;
119 ;;; You should not use them.
120
121 (defalias 'char-leading-char 'char-charset)
122
123 (defun char-category (character)
124   "Return string of category mnemonics for CHAR in TABLE.
125 CHAR can be any multilingual character
126 TABLE defaults to the current buffer's category table."
127   (mapconcat (lambda (chr)
128                (char-to-string (int-char chr))
129                )
130              (char-category-list character)
131              ""))
132
133
134 ;;; @ string
135 ;;;
136
137 (defun string-to-int-list (str)
138   (mapcar #'char-int str)
139   )
140
141
142 ;;; @ end
143 ;;;
144
145 (provide 'emu-x20)
146
147 ;;; emu-x20.el ends here