Function: mail-unquote-printable

mail-unquote-printable is an autoloaded and byte-compiled function defined in mail-utils.el.gz.

Signature

(mail-unquote-printable STRING &optional WRAPPER)

Documentation

Undo the "quoted printable" encoding.

If the optional argument WRAPPER is non-nil, we expect to find and remove the wrapper characters =?ISO-8859-1?Q?....?=.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/mail-utils.el.gz
;;;###autoload
(defun mail-unquote-printable (string &optional wrapper)
  "Undo the \"quoted printable\" encoding.
If the optional argument WRAPPER is non-nil,
we expect to find and remove the wrapper characters =?ISO-8859-1?Q?....?=."
  (save-match-data
    (and wrapper
	 (string-match "\\`=\\?ISO-8859-1\\?Q\\?\\([^?]*\\)\\?" string)
	 (setq string (match-string 1 string)))
    (let ((i 0) strings)
      (while (string-match "=\\(..\\|\n\\)" string i)
	(setq strings (cons (substring string i (match-beginning 0)) strings))
	(unless (= (aref string (match-beginning 1)) ?\n)
	  (setq strings
		(cons (make-string 1
				   (+ (* 16 (mail-unquote-printable-hexdigit
					     (aref string (match-beginning 1))))
				      (mail-unquote-printable-hexdigit
				       (aref string (1+ (match-beginning 1))))))
		      strings)))
	(setq i (match-end 0)))
      (apply #'concat (nreverse (cons (substring string i) strings))))))