1 ;;; mcs-e20.el --- MIME charset implementation for Emacs 20.1 and 20.2
3 ;; Copyright (C) 1996,1997,1998 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: emulation, compatibility, Mule
8 ;; This file is part of APEL (A Portable Emacs Library).
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; This module requires Emacs 20.1 and 20.2.
31 (defsubst encode-mime-charset-region (start end charset)
32 "Encode the text between START and END as MIME CHARSET."
34 (if (and enable-multibyte-characters
35 (setq cs (mime-charset-to-coding-system charset)))
36 (encode-coding-region start end cs)
39 (defsubst decode-mime-charset-region (start end charset &optional lbt)
40 "Decode the text between START and END as MIME CHARSET."
42 (if (and enable-multibyte-characters
43 (setq cs (mime-charset-to-coding-system charset lbt)))
44 (decode-coding-region start end cs)
48 (defsubst encode-mime-charset-string (string charset)
49 "Encode the STRING as MIME CHARSET."
51 (if (and enable-multibyte-characters
52 (setq cs (mime-charset-to-coding-system charset)))
53 (encode-coding-string string cs)
56 (defsubst decode-mime-charset-string (string charset &optional lbt)
57 "Decode the STRING as MIME CHARSET."
59 (if (and enable-multibyte-characters
60 (setq cs (mime-charset-to-coding-system charset lbt)))
61 (decode-coding-string string cs)
65 (defvar charsets-mime-charset-alist
66 '(((ascii) . us-ascii)
67 ((ascii latin-iso8859-1) . iso-8859-1)
68 ((ascii latin-iso8859-2) . iso-8859-2)
69 ((ascii latin-iso8859-3) . iso-8859-3)
70 ((ascii latin-iso8859-4) . iso-8859-4)
71 ;;; ((ascii cyrillic-iso8859-5) . iso-8859-5)
72 ((ascii cyrillic-iso8859-5) . koi8-r)
73 ((ascii arabic-iso8859-6) . iso-8859-6)
74 ((ascii greek-iso8859-7) . iso-8859-7)
75 ((ascii hebrew-iso8859-8) . iso-8859-8)
76 ((ascii latin-iso8859-9) . iso-8859-9)
77 ((ascii latin-jisx0201
78 japanese-jisx0208-1978 japanese-jisx0208) . iso-2022-jp)
79 ((ascii latin-jisx0201
80 katakana-jisx0201 japanese-jisx0208) . shift_jis)
81 ((ascii korean-ksc5601) . euc-kr)
82 ((ascii chinese-gb2312) . gb2312)
83 ((ascii chinese-big5-1 chinese-big5-2) . big5)
84 ((ascii latin-iso8859-1 greek-iso8859-7
85 latin-jisx0201 japanese-jisx0208-1978
86 chinese-gb2312 japanese-jisx0208
87 korean-ksc5601 japanese-jisx0212) . iso-2022-jp-2)
88 ((ascii latin-iso8859-1 greek-iso8859-7
89 latin-jisx0201 japanese-jisx0208-1978
90 chinese-gb2312 japanese-jisx0208
91 korean-ksc5601 japanese-jisx0212
92 chinese-cns11643-1 chinese-cns11643-2) . iso-2022-int-1)
93 ((ascii latin-iso8859-1 latin-iso8859-2
94 cyrillic-iso8859-5 greek-iso8859-7
95 latin-jisx0201 japanese-jisx0208-1978
96 chinese-gb2312 japanese-jisx0208
97 korean-ksc5601 japanese-jisx0212
98 chinese-cns11643-1 chinese-cns11643-2
99 chinese-cns11643-3 chinese-cns11643-4
100 chinese-cns11643-5 chinese-cns11643-6
101 chinese-cns11643-7) . iso-2022-int-1)
105 (defun coding-system-to-mime-charset (coding-system)
106 "Convert CODING-SYSTEM to a MIME-charset.
107 Return nil if corresponding MIME-charset is not found."
108 (or (car (rassq coding-system mime-charset-coding-system-alist))
109 (coding-system-get coding-system 'mime-charset)))
111 (defun mime-charset-list ()
112 "Return a list of all existing MIME-charset."
113 (let ((dest (mapcar (function car) mime-charset-coding-system-alist))
114 (rest coding-system-list)
118 (unless (rassq cs mime-charset-coding-system-alist)
119 (if (setq cs (coding-system-get cs 'mime-charset))
120 (or (rassq cs mime-charset-coding-system-alist)
122 (setq dest (cons cs dest))
124 (setq rest (cdr rest)))
135 ;;; mcs-e20.el ends here