[Mew-dist 1709] Re: guess 漢字 encoding in multipart message

Kazu Yamamoto ( 山本和彦 ) Kazu at example.com
1997年 8月 28日 (木) 13:43:19 JST


とりあえず、charset の guess と MIME encoding を直行させるパッチです。
ISO-2022-JP{,-2}, EUC Japan, ISO-8859-2 では実験しました。その他いろいろ
試してもらえると幸いです。

--かず

*** mew-encode.el.orig	Thu Aug 28 11:52:40 1997
--- mew-encode.el	Thu Aug 28 13:00:36 1997
***************
*** 148,162 ****
    (cdr (mew-assoc-match cte mew-prog-mime-encode-text-switch 0))
    )
  
! (defun mew-encode-text-magic (file ctl cte)
    ;; return (file charset cte encopts)
    (let* ((charset (mew-syntax-get-member ctl "charset"))
! 	 ;; charset exists only when buffered is nil
! 	 encopts)
!     (if (eq file t) (setq file nil)) ;; file is t if buffered
      (if (and charset cte)
! 	(list file charset cte (mew-encode-get-topts cte))
!       (if file
  	  ;; Even if charset is specified, we need to check the entire
  	  ;; text object for cte to escape "\nFrom ".
  	  (mew-frwlet
--- 148,162 ----
    (cdr (mew-assoc-match cte mew-prog-mime-encode-text-switch 0))
    )
  
! (defun mew-encode-text-magic (infile ctl cte)
    ;; return (file charset cte encopts)
+   ;; If infile is 't', target is buffered.
    (let* ((charset (mew-syntax-get-member ctl "charset"))
! 	 ;; charset exists only when file is not buffered.
! 	 encopts outfile)
      (if (and charset cte)
! 	(list infile charset cte (mew-encode-get-topts cte)) ;; return
!       (if (stringp infile)
  	  ;; Even if charset is specified, we need to check the entire
  	  ;; text object for cte to escape "\nFrom ".
  	  (mew-frwlet
***************
*** 164,176 ****
  	   ;; Input the text file converting its charset to the internel.
  	   ;; If charset is specified, use it.
  	   ;; If mew-cs-infile is *autoconv*/'autodetect, charset is guessed
! 	   ;; but its rule depends on the user environment.
! 	   ;; For example, for usual Japanese, file is assumed as
! 	   ;; ISO-2022-JP, EUC-Japan, or SJIS on Mule.
! 	   (insert-file-contents file)
  	   )
- 	() ;; buffered
  	)
        ;; Let's guess charset if not specified. The charset of CoverPage 
        ;; for just singlepart(buffered) is always guessed.
        ;; Even if the file is EUC-Japan, charset is guessed as ISO-2022-JP.
--- 164,174 ----
  	   ;; Input the text file converting its charset to the internel.
  	   ;; If charset is specified, use it.
  	   ;; If mew-cs-infile is *autoconv*/'autodetect, charset is guessed
! 	   ;; but Mule's heuristic.
! 	   (insert-file-contents infile)
  	   )
  	)
+       ;; Target is now certainly bufferd.
        ;; Let's guess charset if not specified. The charset of CoverPage 
        ;; for just singlepart(buffered) is always guessed.
        ;; Even if the file is EUC-Japan, charset is guessed as ISO-2022-JP.
***************
*** 178,183 ****
--- 176,182 ----
        ;; charset is guessed as ISO-8859-1.
        (if (null charset) 
  	  (setq charset (mew-charset-guess-region (point) (point-max))))
+       ;; Guess cte for mewencode executed later.
        (if cte
  	  (setq encopts (mew-encode-get-topts cte))
  	(if (mew-charset-8bit-p charset)
***************
*** 191,210 ****
  		(setq cte mew-qp encopts (mew-encode-get-topts mew-qp))
  	      (setq cte "7bit" encopts nil)))))
        (if (null encopts)
! 	  (setq file nil) ;; Not encode a file
! 	(if (not file)
! 	    (mew-frwlet
! 	     mew-cs-noconv (mew-charset-to-cs charset)
! 	     (if (not (file-exists-p mew-temp-dir))
! 		 (mew-make-directory mew-temp-dir)) ;; just in case
! 	     (setq file (make-temp-name mew-temp-file))
! 	     ;; Write the text as MIME charset
! 	     ;; from internal to MIME charset (e.g. ISO-2022-JP)
! 	     ;; NEVER use call-process-region for privary reasons
! 	     (write-region (point) (point-max) file)))
! 	;; the file is used, so delete the region.
  	(delete-region (point) (point-max)))
!       (list file charset cte encopts)
        )))
  
  (defun mew-encode-singlepart (syntax &optional path depth buffered)
--- 190,207 ----
  		(setq cte mew-qp encopts (mew-encode-get-topts mew-qp))
  	      (setq cte "7bit" encopts nil)))))
        (if (null encopts)
! 	  ()
! 	;; We MUST save text since charset MAY change.
! 	(mew-frwlet
! 	 mew-cs-noconv (mew-charset-to-cs charset)
! 	 (if (not (file-exists-p mew-temp-dir))
! 	     (mew-make-directory mew-temp-dir)) ;; just in case
! 	 (setq outfile (make-temp-name mew-temp-file))
! 	 ;; NEVER use call-process-region for privary reasons
! 	 (write-region (point) (point-max) outfile))
! 	;; outfile will be used, so delete the region.
  	(delete-region (point) (point-max)))
!       (list outfile charset cte encopts)
        )))
  
  (defun mew-encode-singlepart (syntax &optional path depth buffered)




Mew-dist メーリングリストの案内