"\\("
mime-charset-regexp
"\\)"
+ "\\(\\*\\([^?]+\\)\\)?"
(regexp-quote "?")
"\\([BbQq]\\)"
(regexp-quote "?")
"\\(\n?[ \t]\\)+"
"\\(" eword-encoded-word-regexp "\\)")
nil t)
- (replace-match "\\1\\6")
+ (replace-match "\\1\\8")
(goto-char (point-min))
)
(while (re-search-forward eword-encoded-word-regexp nil t)
(let ((charset
(substring word (match-beginning 1) (match-end 1))
)
+ (language
+ (when (match-beginning 3)
+ (intern
+ (downcase
+ (substring word (match-beginning 3) (match-end 3))
+ ))))
(encoding
(upcase
- (substring word (match-beginning 2) (match-end 2))
+ (substring word (match-beginning 4) (match-end 4))
))
(text
- (substring word (match-beginning 3) (match-end 3))
+ (substring word (match-beginning 5) (match-end 5))
))
- (condition-case err
- (eword-decode-encoded-text charset encoding text must-unfold)
- (error
+ (condition-case err
+ (eword-decode-encoded-text charset encoding text
+ must-unfold language)
+ (error
(funcall eword-decode-encoded-word-error-handler word err)
- ))
- ))
+ ))))
word))
;;;
(defun eword-decode-encoded-text (charset encoding string
- &optional must-unfold)
+ &optional must-unfold language)
"Decode STRING as an encoded-text.
If your emacs implementation can not decode CHARSET, it returns nil.
If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even
if there are in decoded encoded-text (generated by bad manner MUA such
-as a version of Net$cape)."
+as a version of Net$cape).
+
+If LANGUAGE is non-nil, put this value as text-property `mime-language'
+to result text."
(let ((cs (mime-charset-to-coding-system charset)))
(if cs
(let ((dest (encoded-text-decode-string string encoding)))
(when dest
(setq dest (decode-mime-charset-string dest charset))
- (if must-unfold
- (mapconcat (function
- (lambda (chr)
- (cond ((eq chr ?\n) "")
- ((eq chr ?\t) " ")
- (t (char-to-string chr)))
- ))
- (std11-unfold-string dest)
- "")
- dest))))))
+ (when must-unfold
+ (setq dest (mapconcat (function
+ (lambda (chr)
+ (cond ((eq chr ?\n) "")
+ ((eq chr ?\t) " ")
+ (t (char-to-string chr)))
+ ))
+ (std11-unfold-string dest)
+ "")))
+ (when language
+ (put-text-property 0 (length dest) 'mime-language language dest)
+ )
+ dest)))))
;;; @ lexical analyze