word))
(defun eword-decode-encoded-word (word &optional must-unfold)
- "Decode WORD if it is an encoded-word.
-
-If your emacs implementation can not decode the charset of WORD, it
-returns WORD. Similarly the encoded-word is broken, it returns WORD.
-
-If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even
-if there are in decoded encoded-word (generated by bad manner MUA such
-as a version of Net$cape)."
- (or (if (string-match eword-encoded-word-regexp word)
- (let ((charset
- (substring word (match-beginning 1)(match-end 1)))
- (language
- (when (match-beginning 2)
- (intern
- (downcase
- (substring word (1+ (match-beginning 2))(match-end 2))))))
- (encoding
- (upcase
- (substring word (match-beginning 3)(match-end 3))))
- (text
- (substring word (match-beginning 4)(match-end 4))))
- (condition-case err
- (eword-decode-encoded-text
- charset language encoding text must-unfold)
- (error
- (funcall eword-decode-encoded-word-error-handler word err)))))
+ "Decode WORD as an encoded-word.
+
+If charset is unknown or unsupported, return WORD.
+If encoding is unknown, or some error occurs while decoding,
+`eword-decode-encoded-word-error-handler' is called with WORD and an
+error condition.
+
+If MUST-UNFOLD is non-nil, unfold decoded WORD."
+ (or (and (string-match eword-encoded-word-regexp word)
+ (condition-case err
+ (eword-decode-encoded-text
+ ;; charset
+ (substring word (match-beginning 1)(match-end 1))
+ ;; language
+ (when (match-beginning 2)
+ (intern
+ (downcase
+ (substring word (1+ (match-beginning 2))(match-end 2)))))
+ ;; encoding
+ (upcase
+ (substring word (match-beginning 3)(match-end 3)))
+ ;; encoded-text
+ (substring word (match-beginning 4)(match-end 4))
+ must-unfold)
+ (error
+ (funcall eword-decode-encoded-word-error-handler word err))))
word))