Importing pgnus-0.25.
[elisp/gnus.git-] / lisp / mm-bodies.el
index 9de7f36..0e6640b 100644 (file)
@@ -51,7 +51,8 @@ If no encoding was done, nil is returned."
        charsets)
        ;; We encode.
        (t
-       (let ((mime-charset (mm-mule-charset-to-mime-charset (car charsets)))
+       (let ((mime-charset 
+              (mm-mime-charset (car charsets) (point-min) (point-max)))
              start)
          (when (or t
                    ;; We always decode.
@@ -78,14 +79,9 @@ If no encoding was done, nil is returned."
        ;;;!!!above seems to return the wrong result under Emacs 20.3.
        ;;;!!!Sometimes.
        (save-excursion
-        (let (found)
-          (goto-char (point-min))
-          (while (and (not found)
-                      (not (eobp)))
-            (when (> (mm-char-int (following-char)) 127)
-              (setq found t))
-            (forward-char 1))
-          (not found))))
+        (goto-char (point-min))
+        (skip-chars-forward "\0-\177")
+        (eobp)))
       '7bit
     '8bit))
 
@@ -93,25 +89,28 @@ If no encoding was done, nil is returned."
 ;;; Functions for decoding
 ;;;
 
+(defun mm-decode-content-transfer-encoding (encoding)
+  (cond
+   ((eq encoding 'quoted-printable)
+    (quoted-printable-decode-region (point-min) (point-max)))
+   ((eq encoding 'base64)
+    (condition-case ()
+       (base64-decode-region (point-min) (point-max))
+      (error nil)))
+   ((memq encoding '(7bit 8bit binary))
+    )
+   ((null encoding)
+    )
+   (t
+    (error "Can't decode encoding %s" encoding))))
+
 (defun mm-decode-body (charset encoding)
   "Decode the current article that has been encoded with ENCODING.
 The characters in CHARSET should then be decoded."
   (setq charset (or charset rfc2047-default-charset))
   (save-excursion
     (when encoding
-      (cond
-       ((eq encoding 'quoted-printable)
-       (quoted-printable-decode-region (point-min) (point-max)))
-       ((eq encoding 'base64)
-       (condition-case ()
-           (base64-decode-region (point-min) (point-max))
-         (error nil)))
-       ((memq encoding '(7bit 8bit binary))
-       )
-       ((null encoding)
-       )
-       (t
-       (error "Can't decode encoding %s" encoding))))
+      (mm-decode-content-transfer-encoding encoding))
     (when (featurep 'mule)
       (let (mule-charset)
        (when (and charset