Function: mm-encode-body
mm-encode-body is an autoloaded and byte-compiled function defined in
mm-bodies.el.gz.
Signature
(mm-encode-body &optional CHARSET)
Documentation
Encode whole buffer's contents.
Buffer's multibyteness will be turned off when encoding takes place. If there is more than one non-ASCII MULE charset in the body, then the list of MULE charsets found is returned. If CHARSET is non-nil, it is used as the MIME charset to encode the body. If successful, the MIME charset is returned. If no encoding was done, nil is returned.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/mm-bodies.el.gz
(defun mm-encode-body (&optional charset)
"Encode whole buffer's contents.
Buffer's multibyteness will be turned off when encoding takes place.
If there is more than one non-ASCII MULE charset in the body, then the
list of MULE charsets found is returned.
If CHARSET is non-nil, it is used as the MIME charset to encode the body.
If successful, the MIME charset is returned.
If no encoding was done, nil is returned."
(if (not enable-multibyte-characters)
;; In the non-Mule case, we search for non-ASCII chars and
;; return the value of `mail-parse-charset' if any are found.
(or charset
(save-excursion
(goto-char (point-min))
(if (re-search-forward "[^\x0-\x7f]" nil t)
(or mail-parse-charset
(message-options-get 'mm-body-charset-encoding-alist)
(message-options-set
'mm-body-charset-encoding-alist
(read-coding-system "Charset used in the article: ")))
;; The logic in `mml-generate-mime-1' confirms that it's OK
;; to return nil here.
nil)))
(save-excursion
(if charset
(progn
(insert
(prog1
(encode-coding-string (buffer-string)
(mm-charset-to-coding-system charset))
(erase-buffer)
(set-buffer-multibyte nil)))
charset)
(goto-char (point-min))
(let ((charsets (mm-find-mime-charset-region (point-min) (point-max)
mm-hack-charsets)))
(cond
;; No encoding.
((null charsets)
nil)
;; Too many charsets.
((> (length charsets) 1)
charsets)
;; We encode.
(t
(prog1
(setq charset (car charsets))
(insert
(prog1
(encode-coding-string (buffer-string)
(mm-charset-to-coding-system charset))
(erase-buffer)
(set-buffer-multibyte nil)))))
))))))