Function: mm-decode-content-transfer-encoding
mm-decode-content-transfer-encoding is a byte-compiled function
defined in mm-bodies.el.gz.
Signature
(mm-decode-content-transfer-encoding ENCODING &optional TYPE)
Documentation
Decodes buffer encoded with ENCODING, returning success status.
If TYPE is text/plain CRLF->LF translation may occur.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/mm-bodies.el.gz
;;;
;;; Functions for decoding
;;;
(defun mm-decode-content-transfer-encoding (encoding &optional type)
"Decodes buffer encoded with ENCODING, returning success status.
If TYPE is `text/plain' CRLF->LF translation may occur."
(prog1
(condition-case error
(cond
((eq encoding 'quoted-printable)
(quoted-printable-decode-region (point-min) (point-max))
t)
((eq encoding 'base64)
(base64-decode-region
(point-min)
;; Some mailers insert whitespace
;; junk at the end which
;; base64-decode-region dislikes.
;; Also remove possible junk which could
;; have been added by mailing list software.
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^[\t ]*\r?\n" nil t)
(delete-region (match-beginning 0) (match-end 0)))
(goto-char (point-max))
(when (re-search-backward "^[\t ]*[A-Za-z0-9+/]+=*[\t ]*$"
nil t)
(forward-line))
(point))))
((memq encoding '(nil 7bit 8bit binary))
;; Do nothing.
t)
((memq encoding '(x-uuencode x-uue))
(require 'mm-uu)
(funcall mm-uu-decode-function (point-min) (point-max))
t)
((eq encoding 'x-binhex)
(require 'mm-uu)
(funcall mm-uu-binhex-decode-function (point-min) (point-max))
t)
((eq encoding 'x-yenc)
(require 'mm-uu)
(funcall mm-uu-yenc-decode-function (point-min) (point-max))
)
((functionp encoding)
(funcall encoding (point-min) (point-max))
t)
(t
(message "Unknown encoding %s; defaulting to 8bit" encoding)))
(error
(message "Error while decoding: %s" error)
nil))
(when (and
type
(memq encoding '(base64 x-uuencode x-uue x-binhex x-yenc))
(string-match "\\`text/" type))
(goto-char (point-min))
(while (search-forward "\r\n" nil t)
(replace-match "\n" t t)))))