tm 7.40.
[elisp/tm.git] / tm-mule.el
1 ;;;
2 ;;; tm-mule.el --- tm definitions depended on Mule
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1994,1995,1996 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Version:
9 ;;;     $Id: tm-mule.el,v 7.6 1996/01/11 05:09:28 morioka Exp $
10 ;;; Keywords: mail, news, MIME, multimedia, multilingual, encoded-word
11 ;;;
12 ;;; This file is part of tm (Tools for MIME).
13 ;;;
14 ;;; This program is free software; you can redistribute it and/or
15 ;;; modify it under the terms of the GNU General Public License as
16 ;;; published by the Free Software Foundation; either version 2, or
17 ;;; (at your option) any later version.
18 ;;;
19 ;;; This program is distributed in the hope that it will be useful,
20 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22 ;;; General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with This program.  If not, write to the Free Software
26 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;;;
28 ;;; Code:
29
30 (require 'emu)
31 (require 'tl-list)
32
33
34 ;;; @ coding-system
35 ;;;
36
37 (defvar mime/default-coding-system *ctext*)
38
39 (defvar mime/charset-coding-system-alist
40   '(("ISO-2022-JP"     . *iso-2022-ss2-7*)
41     ("ISO-2022-JP-2"   . *iso-2022-ss2-7*)
42     ("X-ISO-2022-JP-2" . *iso-2022-ss2-7*)
43     ("ISO-2022-CN"     . *iso-2022-ss2-7*)
44     ("ISO-2022-KR"     . *iso-2022-kr*)
45     ("EUC-KR"          . *euc-kr*)
46     ("ISO-8859-1"      . *ctext*)
47     ("ISO-8859-2"      . *iso-8859-2*)
48     ("ISO-8859-3"      . *iso-8859-3*)
49     ("ISO-8859-4"      . *iso-8859-4*)
50     ("ISO-8859-5"      . *iso-8859-5*)
51     ("ISO-8859-7"      . *iso-8859-7*)
52     ("ISO-8859-8"      . *iso-8859-8*)
53     ("ISO-8859-9"      . *iso-8859-9*)
54     ("ISO-2022-INT-1"  . *iso-2022-int-1*)
55     ))
56
57
58 ;;; @ leading-character and charset
59 ;;;
60
61 (defvar mime/lc-charset-alist
62   (list
63    (cons (list lc-ascii)         "US-ASCII")
64    (cons (list lc-ascii lc-ltn1) "ISO-8859-1")
65    (cons (list lc-ascii lc-ltn2) "ISO-8859-2")
66    (cons (list lc-ascii lc-ltn3) "ISO-8859-3")
67    (cons (list lc-ascii lc-ltn4) "ISO-8859-4")
68 ;;;(cons (list lc-ascii lc-crl)  "ISO-8859-5")
69    (cons (list lc-ascii lc-crl)  "KOI8-R")
70    (cons (list lc-ascii lc-grk)  "ISO-8859-7")
71    (cons (list lc-ascii lc-hbw)  "ISO-8859-8")
72    (cons (list lc-ascii lc-ltn5) "ISO-8859-9")
73    (cons (list lc-ascii lc-jp)   "ISO-2022-JP")
74    (cons (list lc-ascii lc-kr)   "EUC-KR")
75    (cons (list lc-ascii
76                lc-jp lc-cn
77                lc-kr lc-jp2
78                lc-ltn1 lc-grk) "ISO-2022-JP-2")
79    (cons (list lc-ascii
80                lc-jp lc-cn
81                lc-kr lc-jp2
82                lc-cns1 lc-cns2
83                lc-ltn1 lc-grk) "ISO-2022-INT-1")
84    ))
85
86 (defvar mime/unknown-charset "ISO-2022-INT-1")
87
88
89 ;;; @ functions
90 ;;;
91
92 (defun mime/convert-string-to-emacs (charset str)
93   (let ((cs (cdr (assoc charset mime/charset-coding-system-alist))))
94     (if cs
95         (code-convert-string str cs *internal*)
96       )))
97
98 (defun mime/convert-string-from-emacs (str charset)
99   (let ((cs (cdr (assoc charset mime/charset-coding-system-alist))))
100     (if cs
101         (code-convert-string str *internal* cs)
102       )))
103
104 (defun mime/code-convert-region-to-emacs (beg end charset &optional encoding)
105   (if (stringp charset)
106       (progn
107         (setq charset (upcase charset))
108         (let ((ct (cdr (assoc charset mime/charset-coding-system-alist))))
109           (if ct
110               (code-convert beg end ct *internal*)
111             )))
112     (if mime/default-coding-system
113         (code-convert beg end mime/default-coding-system *internal*)
114       )))
115
116
117 ;;; @ end
118 ;;;
119
120 (provide 'tm-mule)
121
122 (run-hooks 'tm-mule-load-hook)
123
124 ;;; tm-mule.el ends here