From: morioka Date: Sat, 20 Jun 1998 20:58:32 +0000 (+0000) Subject: (mime-string-decoding-method-alist): New variable. X-Git-Tag: flim-1_5_0~16 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dffc86833d4794229d30c034041869f17f1a88fe;p=elisp%2Fflim.git (mime-string-decoding-method-alist): New variable. (mime-decode-string): New function. --- diff --git a/mel.el b/mel.el index 01efaf2..bb8150d 100644 --- a/mel.el +++ b/mel.el @@ -149,6 +149,19 @@ STRING is content-transfer-encoding. FUNCTION is region decoder.") ;;;###autoload +(defvar mime-string-decoding-method-alist + '(("base64" . base64-decode-string) + ("quoted-printable" . quoted-printable-decode-string) + ("7bit" . identity) + ("8bit" . identity) + ("binary" . identity) + ) + "Alist of encoding vs. corresponding method to decode string. +Each element looks like (STRING . FUNCTION). +STRING is content-transfer-encoding. +FUNCTION is string decoder.") + +;;;###autoload (defun mime-encode-region (start end encoding) "Encode region START to END of current buffer using ENCODING. ENCODING must be string. If ENCODING is found in @@ -182,6 +195,21 @@ region by its value." (funcall f start end) ))) +;;;###autoload +(defun mime-decode-string (string encoding) + "Decode STRING using ENCODING. +ENCODING must be string. If ENCODING is found in +`mime-string-decoding-method-alist' as its key, this function decodes +the STRING by its value." + (let ((f (cdr (assoc encoding mime-string-decoding-method-alist)))) + (if f + (funcall f string) + (with-temp-buffer + (insert string) + (mime-decode-region (point-min)(point-max) encoding) + (buffer-string) + )))) + ;;; @ file ;;;