Function: rfc2047-decode-string
rfc2047-decode-string is a byte-compiled function defined in
rfc2047.el.gz.
Signature
(rfc2047-decode-string STRING &optional ADDRESS-MIME)
Documentation
Decode MIME-encoded STRING and return the result.
If ADDRESS-MIME is non-nil, strip backslashes which precede characters
other than " and \ in quoted strings.
Aliases
mail-decode-encoded-word-string
Source Code
;; Defined in /usr/src/emacs/lisp/mail/rfc2047.el.gz
(defun rfc2047-decode-string (string &optional address-mime)
"Decode MIME-encoded STRING and return the result.
If ADDRESS-MIME is non-nil, strip backslashes which precede characters
other than `\"' and `\\' in quoted strings."
(if (string-search "=?" string)
(with-temp-buffer
;; We used to only call mm-enable-multibyte if `m' is non-nil,
;; but this can't be the right criterion. Don't just revert this
;; change if it encounters a bug. Please help me fix it
;; right instead. --Stef
;; The string returned should always be multibyte in a multibyte
;; session, i.e. the buffer should be multibyte before
;; `buffer-string' is called.
(mm-enable-multibyte)
(insert string)
(inline
(rfc2047-decode-region (point-min) (point-max) address-mime))
(buffer-string))
(when address-mime
(setq string
(with-temp-buffer
(when (multibyte-string-p string)
(mm-enable-multibyte))
(insert string)
(rfc2047-strip-backslashes-in-quoted-strings)
(buffer-string))))
;; Fixme: As above, `m' here is inappropriate.
(if (and ;; m
mail-parse-charset
(not (eq mail-parse-charset 'us-ascii))
(not (eq mail-parse-charset 'gnus-decoded)))
;; `decode-coding-string' in Emacs offers a third optional
;; arg NOCOPY to avoid consing a new string if the decoding
;; is "trivial". Unfortunately it currently doesn't
;; consider anything else than a nil coding system
;; trivial.
;; `rfc2047-decode-string' is called multiple times for each
;; article during summary buffer generation, and we really
;; want to avoid unnecessary consing. So we bypass
;; `decode-coding-string' if the string is purely ASCII.
(if (eq (detect-coding-string string t) 'undecided)
;; string is purely ASCII
string
(decode-coding-string string mail-parse-charset))
(if (multibyte-string-p string)
string
(decode-coding-string string 'us-ascii)))))