tm 7.41.2.
[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 .. 1996 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Version:
9 ;;;     $Id: tm-mule.el,v 7.7 1996/01/25 02:32:26 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/charset-coding-system-alist
38   '(("ISO-2022-JP"     . *iso-2022-ss2-7*)
39     ("ISO-2022-JP-2"   . *iso-2022-ss2-7*)
40     ("X-ISO-2022-JP-2" . *iso-2022-ss2-7*)
41     ("ISO-2022-CN"     . *iso-2022-ss2-7*)
42     ("ISO-2022-KR"     . *iso-2022-kr*)
43     ("EUC-KR"          . *euc-kr*)
44     ("ISO-8859-1"      . *ctext*)
45     ("ISO-8859-2"      . *iso-8859-2*)
46     ("ISO-8859-3"      . *iso-8859-3*)
47     ("ISO-8859-4"      . *iso-8859-4*)
48     ("ISO-8859-5"      . *iso-8859-5*)
49     ("ISO-8859-7"      . *iso-8859-7*)
50     ("ISO-8859-8"      . *iso-8859-8*)
51     ("ISO-8859-9"      . *iso-8859-9*)
52     ("ISO-2022-INT-1"  . *iso-2022-int-1*)
53     ))
54
55
56 ;;; @ leading-character and charset
57 ;;;
58
59 (defvar mime/lc-charset-alist
60   (list
61    (cons (list lc-ascii)         "US-ASCII")
62    (cons (list lc-ascii lc-ltn1) "ISO-8859-1")
63    (cons (list lc-ascii lc-ltn2) "ISO-8859-2")
64    (cons (list lc-ascii lc-ltn3) "ISO-8859-3")
65    (cons (list lc-ascii lc-ltn4) "ISO-8859-4")
66 ;;;(cons (list lc-ascii lc-crl)  "ISO-8859-5")
67    (cons (list lc-ascii lc-crl)  "KOI8-R")
68    (cons (list lc-ascii lc-grk)  "ISO-8859-7")
69    (cons (list lc-ascii lc-hbw)  "ISO-8859-8")
70    (cons (list lc-ascii lc-ltn5) "ISO-8859-9")
71    (cons (list lc-ascii lc-jp)   "ISO-2022-JP")
72    (cons (list lc-ascii lc-kr)   "EUC-KR")
73    (cons (list lc-ascii
74                lc-jp lc-cn
75                lc-kr lc-jp2
76                lc-ltn1 lc-grk) "ISO-2022-JP-2")
77    (cons (list lc-ascii
78                lc-jp lc-cn
79                lc-kr lc-jp2
80                lc-cns1 lc-cns2
81                lc-ltn1 lc-grk) "ISO-2022-INT-1")
82    ))
83
84 (defvar mime/unknown-charset "ISO-2022-INT-1")
85
86
87 ;;; @ functions
88 ;;;
89
90 (defun mime/convert-string-to-emacs (charset str)
91   (let ((cs (cdr (assoc charset mime/charset-coding-system-alist))))
92     (if cs
93         (code-convert-string str cs *internal*)
94       )))
95
96 (defun mime/convert-string-from-emacs (str charset)
97   (let ((cs (cdr (assoc charset mime/charset-coding-system-alist))))
98     (if cs
99         (code-convert-string str *internal* cs)
100       )))
101
102 (defun mime/code-convert-region-to-emacs (beg end charset &optional encoding)
103   (if (stringp charset)
104       (progn
105         (setq charset (upcase charset))
106         (let ((ct (cdr (assoc charset mime/charset-coding-system-alist))))
107           (if ct
108               (code-convert beg end ct *internal*)
109             )))
110     (if mime/default-coding-system
111         (code-convert beg end mime/default-coding-system *internal*)
112       )))
113
114
115 ;;; @ end
116 ;;;
117
118 (provide 'tm-mule)
119
120 (run-hooks 'tm-mule-load-hook)
121
122 ;;; tm-mule.el ends here