2000-11-13 20:43:37 ShengHuo ZHU <zsh@cs.rochester.edu>
authorShengHuo ZHU <zsh@cs.rochester.edu>
Tue, 14 Nov 2000 01:16:26 +0000 (01:16 +0000)
committerShengHuo ZHU <zsh@cs.rochester.edu>
Tue, 14 Nov 2000 01:16:26 +0000 (01:16 +0000)
* mm-decode.el (mm-get-part): Don't call mm-insert-part.
* mml.el (mml-generate-mime-1): Use charset attribute.
* mm-bodies.el (mm-encode-body): Add parameter charset.
* mm-util.el (mm-mime-charset): Show error when find 8-bit characters.

lisp/ChangeLog
lisp/mm-bodies.el
lisp/mm-decode.el
lisp/mm-util.el
lisp/mml.el

index 98b3391..8cf0fa0 100644 (file)
@@ -1,3 +1,10 @@
+2000-11-13 20:43:37  ShengHuo ZHU  <zsh@cs.rochester.edu>
+
+       * mm-decode.el (mm-get-part): Don't call mm-insert-part.
+       * mml.el (mml-generate-mime-1): Use charset attribute.
+       * mm-bodies.el (mm-encode-body): Add parameter charset.
+       * mm-util.el (mm-mime-charset): Show error when find 8-bit characters.
+
 2000-11-13 16:09:09  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * mml2015.el (mml2015-mailcrypt-decrypt): Handle quit.
index f35d273..d4c3677 100644 (file)
@@ -51,60 +51,61 @@ Valid encodings are `7bit', `8bit', `quoted-printable' and `base64'."
                               (const base64))))
   :group 'mime)
 
-(defun mm-encode-body ()
+(defun mm-encode-body (&optional charset)
   "Encode a body.
 Should be called narrowed to the body that is to be encoded.
 If there is more than one non-ASCII MULE charset, then list of found
 MULE charsets are returned.
+If CHARSET is non-nil, it is used.
 If successful, the MIME charset is returned.
 If no encoding was done, nil is returned."
   (if (not (mm-multibyte-p))
       ;; In the non-Mule case, we search for non-ASCII chars and
       ;; return the value of `mail-parse-charset' if any are found.
-      (save-excursion
-       (goto-char (point-min))
-       (if (re-search-forward "[^\x0-\x7f]" nil t)
-           (or mail-parse-charset
-               (message-options-get 'mm-encody-body-charset)
-               (message-options-set 
-                'mm-encody-body-charset
-                (mm-read-charset "Charset used in the article: ")))
-         ;; The logic in `mml-generate-mime-1' confirms that it's OK
-         ;; to return nil here.
-         nil))
+      (or charset
+         (save-excursion
+           (goto-char (point-min))
+           (if (re-search-forward "[^\x0-\x7f]" nil t)
+               (or mail-parse-charset
+                   (message-options-get 'mm-encody-body-charset)
+                   (message-options-set 
+                    'mm-encody-body-charset
+                    (mm-read-charset "Charset used in the article: ")))
+             ;; The logic in `mml-generate-mime-1' confirms that it's OK
+             ;; to return nil here.
+             nil)))
     (save-excursion
-      (goto-char (point-min))
-      (let ((charsets (mm-find-mime-charset-region (point-min) (point-max)))
+      (if charset
+         (progn
+           (mm-encode-coding-region (point-min) (point-max) charset)
            charset)
-       (cond
-        ;; No encoding.
-        ((null charsets)
-         nil)
-        ;; Too many charsets.
-        ((> (length charsets) 1)
-         charsets)
-        ;; We encode.
-        (t
-         (let ((charset (car charsets))
-               start)
-           (when (or t
-                     ;; We always decode.
-                     (not (mm-coding-system-equal
-                           charset buffer-file-coding-system)))
-             (while (not (eobp))
-               (if (eq (mm-charset-after) 'ascii)
-                   (when start
-                     (save-restriction
-                       (narrow-to-region start (point))
-                       (mm-encode-coding-region start (point) charset)
-                       (goto-char (point-max)))
-                     (setq start nil))
-                 (unless start
-                   (setq start (point))))
-               (forward-char 1))
-             (when start
-               (mm-encode-coding-region start (point) charset)
-               (setq start nil)))
+       (goto-char (point-min))
+       (let ((charsets (mm-find-mime-charset-region (point-min) (point-max)))
+             start)
+         (cond
+          ;; No encoding.
+          ((null charsets)
+           nil)
+          ;; Too many charsets.
+          ((> (length charsets) 1)
+           charsets)
+          ;; We encode.
+          (t
+           (setq charset (car charsets))
+           (while (not (eobp))
+             (if (eq (mm-charset-after) 'ascii)
+                 (when start
+                   (save-restriction
+                     (narrow-to-region start (point))
+                     (mm-encode-coding-region start (point) charset)
+                     (goto-char (point-max)))
+                   (setq start nil))
+               (unless start
+                 (setq start (point))))
+             (forward-char 1))
+           (when start
+             (mm-encode-coding-region start (point) charset)
+             (setq start nil))
            charset)))))))
 
 (defun mm-body-encoding (charset &optional encoding)
index 55b9f8a..fb95778 100644 (file)
@@ -740,7 +740,12 @@ external if displayed external."
 (defun mm-get-part (handle)
   "Return the contents of HANDLE as a string."
   (mm-with-unibyte-buffer
-    (mm-insert-part handle)
+    (insert (with-current-buffer (mm-handle-buffer handle)
+             (mm-with-unibyte-current-buffer-mule4
+               (buffer-string))))
+    (mm-decode-content-transfer-encoding
+     (mm-handle-encoding handle)
+     (mm-handle-media-type handle))
     (buffer-string)))
 
 (defun mm-insert-part (handle)
index c6f5192..edd8ae7 100644 (file)
@@ -285,6 +285,8 @@ If the charset is `composition', return the actual one."
 
 (defun mm-mime-charset (charset)
   "Return the MIME charset corresponding to the MULE CHARSET."
+  (if (eq charset 'unknown)
+      (error "8-bit characters are found in the message, please specify charset."))
   (if (and (fboundp 'coding-system-get) (fboundp 'get-charset-property))
       ;; This exists in Emacs 20.
       (or
index 0d8facf..8bafd18 100644 (file)
@@ -292,12 +292,15 @@ If MML is non-nil, return the buffer up till the correspondent mml tag."
          (if (and (not raw)
                   (member (car (split-string type "/")) '("text" "message")))
              (with-temp-buffer
+               (setq charset (mm-charset-to-coding-system 
+                              (cdr (assq 'charset cont))))
                (cond
                 ((cdr (assq 'buffer cont))
                  (insert-buffer-substring (cdr (assq 'buffer cont))))
                 ((and (setq filename (cdr (assq 'filename cont)))
                       (not (equal (cdr (assq 'nofile cont)) "yes")))
-                 (mm-insert-file-contents filename))
+                 (let ((coding-system-for-read charset))
+                   (mm-insert-file-contents filename)))
                 ((eq 'mml (car cont))
                  (insert (cdr (assq 'contents cont))))
                 (t
@@ -324,7 +327,7 @@ If MML is non-nil, return the buffer up till the correspondent mml tag."
                    ;; ignore 0x1b, it is part of iso-2022-jp
                    (setq encoding (mm-body-7-or-8))))
                 (t 
-                 (setq charset (mm-encode-body))
+                 (setq charset (mm-encode-body charset))
                  (setq encoding (mm-body-encoding
                                  charset (cdr (assq 'encoding cont))))))
                (setq coded (buffer-string)))