- (when (featurep 'mule)
- (let (mule-charset)
- (when (and charset
- (setq mule-charset (mm-charset-to-coding-system charset))
- buffer-file-coding-system
- enable-multibyte-characters
- (or (not (eq mule-charset 'ascii))
- (setq mule-charset rfc2047-default-charset)))
- (mm-decode-coding-region (point-min) (point-max) mule-charset))))))
+ (when (and (featurep 'mule) ;; Fixme: Wrong test for unibyte session.
+ (not (eq charset 'gnus-decoded)))
+ (let ((coding-system (mm-charset-to-coding-system
+ ;; Allow overwrite using
+ ;; `mm-charset-override-alist'.
+ charset nil t)))
+ (if (and (not coding-system)
+ (listp mail-parse-ignored-charsets)
+ (memq 'gnus-unknown mail-parse-ignored-charsets))
+ (setq coding-system
+ (mm-charset-to-coding-system mail-parse-charset)))
+ (when (and charset coding-system
+ ;; buffer-file-coding-system
+ ;;Article buffer is nil coding system
+ ;;in XEmacs
+ (mm-multibyte-p)
+ (or (not (eq coding-system 'ascii))
+ (setq coding-system mail-parse-charset)))
+ (mm-decode-coding-region (point-min) (point-max)
+ coding-system))
+ (setq buffer-file-coding-system
+ (if (boundp 'last-coding-system-used)
+ (symbol-value 'last-coding-system-used)
+ coding-system))))))
+
+(defun mm-decode-string (string charset)
+ "Decode STRING with CHARSET."
+ (when (stringp charset)
+ (setq charset (intern (downcase charset))))
+ (when (or (not charset)
+ (eq 'gnus-all mail-parse-ignored-charsets)
+ (memq 'gnus-all mail-parse-ignored-charsets)
+ (memq charset mail-parse-ignored-charsets))
+ (setq charset mail-parse-charset))
+ (or
+ (when (featurep 'mule)
+ (let ((coding-system (mm-charset-to-coding-system
+ charset
+ ;; Allow overwrite using
+ ;; `mm-charset-override-alist'.
+ nil t)))
+ (if (and (not coding-system)
+ (listp mail-parse-ignored-charsets)
+ (memq 'gnus-unknown mail-parse-ignored-charsets))
+ (setq coding-system
+ (mm-charset-to-coding-system mail-parse-charset)))
+ (when (and charset coding-system
+ (mm-multibyte-p)
+ (or (not (eq coding-system 'ascii))
+ (setq coding-system mail-parse-charset)))
+ (mm-decode-coding-string string coding-system))))
+ string))