This commit was generated by cvs2svn to compensate for changes in r434,
[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.9 1996/04/16 13:42:44 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     ("KOI8-R"          . *koi8*)
50     ("ISO-8859-7"      . *iso-8859-7*)
51     ("ISO-8859-8"      . *iso-8859-8*)
52     ("ISO-8859-9"      . *iso-8859-9*)
53     ("ISO-2022-INT-1"  . *iso-2022-int-1*)
54     ("SHIFT_JIS"       . *sjis*)
55     ("X-SHIFTJIS"      . *sjis*)
56     ))
57
58
59 ;;; @ leading-character and charset
60 ;;;
61
62 (defvar mime/lc-charset-alist
63   (list
64    (cons (list lc-ascii)         "US-ASCII")
65    (cons (list lc-ascii lc-ltn1) "ISO-8859-1")
66    (cons (list lc-ascii lc-ltn2) "ISO-8859-2")
67    (cons (list lc-ascii lc-ltn3) "ISO-8859-3")
68    (cons (list lc-ascii lc-ltn4) "ISO-8859-4")
69 ;;;(cons (list lc-ascii lc-crl)  "ISO-8859-5")
70    (cons (list lc-ascii lc-crl)  "KOI8-R")
71    (cons (list lc-ascii lc-grk)  "ISO-8859-7")
72    (cons (list lc-ascii lc-hbw)  "ISO-8859-8")
73    (cons (list lc-ascii lc-ltn5) "ISO-8859-9")
74    (cons (list lc-ascii lc-jp)   "ISO-2022-JP")
75    (cons (list lc-ascii lc-kr)   "EUC-KR")
76    (cons (list lc-ascii
77                lc-jp lc-cn
78                lc-kr lc-jp2
79                lc-ltn1 lc-grk) "ISO-2022-JP-2")
80    (cons (list lc-ascii
81                lc-jp lc-cn
82                lc-kr lc-jp2
83                lc-cns1 lc-cns2
84                lc-ltn1 lc-grk) "ISO-2022-INT-1")
85    ))
86
87 (defvar mime/unknown-charset "ISO-2022-INT-1")
88
89
90 ;;; @ functions
91 ;;;
92
93 (defun mime/convert-string-to-emacs (charset str)
94   (let ((cs (cdr (assoc charset mime/charset-coding-system-alist))))
95     (if cs
96         (code-convert-string str cs *internal*)
97       )))
98
99 (defun mime/convert-string-from-emacs (str charset)
100   (let ((cs (cdr (assoc charset mime/charset-coding-system-alist))))
101     (if cs
102         (code-convert-string str *internal* cs)
103       )))
104
105 (defun mime/code-convert-region-to-emacs (beg end charset &optional encoding)
106   (if (stringp charset)
107       (progn
108         (setq charset (upcase charset))
109         (let ((ct (cdr (assoc charset mime/charset-coding-system-alist))))
110           (if ct
111               (code-convert beg end ct *internal*)
112             )))
113     (if mime/default-coding-system
114         (code-convert beg end mime/default-coding-system *internal*)
115       )))
116
117
118 ;;; @ end
119 ;;;
120
121 (provide 'tm-mule)
122
123 (run-hooks 'tm-mule-load-hook)
124
125 ;;; tm-mule.el ends here