Function: rfc2047-qp-or-base64

rfc2047-qp-or-base64 is a byte-compiled function defined in rfc2047.el.gz.

Signature

(rfc2047-qp-or-base64)

Documentation

Return the type with which to encode the buffer.

This is either base64 or quoted-printable.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rfc2047.el.gz
;;;
;;; Functions for encoding RFC2047 messages
;;;

(defun rfc2047-qp-or-base64 ()
  "Return the type with which to encode the buffer.
This is either `base64' or `quoted-printable'."
  (save-excursion
    (let ((limit (min (point-max) (+ 2000 (point-min))))
	  (n8bit 0))
      (goto-char (point-min))
      (skip-chars-forward "\x20-\x7f\r\n\t" limit)
      (while (< (point) limit)
        (incf n8bit)
	(forward-char 1)
	(skip-chars-forward "\x20-\x7f\r\n\t" limit))
      (if (or (< (* 6 n8bit) (- limit (point-min)))
	      ;; Don't base64, say, a short line with a single
	      ;; non-ASCII char when splitting parts by charset.
	      (= n8bit 1))
	  'quoted-printable
	'base64))))