1 ;;; mcs-ltn1.el --- MIME charset implementation for Emacs 19
2 ;;; and XEmacs without MULE
4 ;; Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc.
6 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
7 ;; Keywords: emulation, compatibility, Mule
9 ;; This file is part of APEL (A Portable Emacs Library).
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
16 ;; This program 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.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
28 (defvar charsets-mime-charset-alist
29 '(((ascii) . us-ascii)))
31 (defvar default-mime-charset 'iso-8859-1)
33 (defsubst lbt-to-string (lbt)
34 (cdr (assq lbt '((nil . nil)
41 (defun mime-charset-to-coding-system (charset &optional lbt)
43 (setq charset (intern (downcase charset))))
44 (if (memq charset (list 'us-ascii default-mime-charset))
47 (defalias 'mime-charset-p 'mime-charset-to-coding-system)
49 (defun detect-mime-charset-region (start end)
50 "Return MIME charset for region between START and END."
53 (re-search-forward "[\200-\377]" end t))
57 (defun encode-mime-charset-region (start end charset &optional lbt)
58 "Encode the text between START and END as MIME CHARSET."
59 (let ((newline (lbt-to-string lbt)))
63 (narrow-to-region start end)
64 (goto-char (point-min))
65 (while (search-forward "\n" nil t)
66 (replace-match newline))
70 (defun decode-mime-charset-region (start end charset &optional lbt)
71 "Decode the text between START and END as MIME CHARSET."
72 (let ((newline (lbt-to-string lbt)))
76 (narrow-to-region start end)
77 (goto-char (point-min))
78 (while (search-forward newline nil t)
83 (defun encode-mime-charset-string (string charset &optional lbt)
84 "Encode the STRING as MIME CHARSET."
88 (encode-mime-charset-region (point-min)(point-max) charset lbt)
92 (defun decode-mime-charset-string (string charset &optional lbt)
93 "Decode the STRING as MIME CHARSET."
97 (decode-mime-charset-region (point-min)(point-max) charset lbt)
101 (defalias 'write-region-as-mime-charset 'write-region)
108 (product-provide (provide 'mcs-ltn1) (require 'apel-ver))
110 ;;; mcs-ltn1.el ends here