(let ((decoded (ew-decode-field "" (ew-lf-crlf-to-crlf string))))
(ew-crlf-to-lf (ew-crlf-unfold decoded))))
+(defun eword-decode-and-unfold-unstructured-field (string)
+ "Decode and unfold STRING as unstructured field body.
+It decodes non us-ascii characters in FULL-NAME encoded as
+encoded-words or invalid \"raw\" string. \"Raw\" non us-ascii
+characters are regarded as variable `default-mime-charset'.
+
+If an encoded-word is broken or your emacs implementation can not
+decode the charset included in it, it is not decoded."
+ (rotate-memo args-eword-decode-and-unfold-unstructured-field
+ (list string))
+ (let ((decoded (ew-decode-field "" (ew-lf-crlf-to-crlf string))))
+ (ew-crlf-to-lf (ew-crlf-unfold decoded))))
+
;;; @ for region
;;;
:group 'eword-decode
:type '(repeat symbol))
+(defun eword-decode-field-body
+ (field-body field-name &optional unfolded max-column)
+ "Decode FIELD-BODY as FIELD-NAME, and return the result.
+
+If UNFOLDED is non-nil, it is assumed that FIELD-BODY is
+already unfolded.
+
+If MAX-COLUMN is non-nil, the result is folded with MAX-COLUMN
+or `fill-column' if MAX-COLUMN is t.
+Otherwise, the result is unfolded.
+
+MIME encoded-word in FIELD-BODY is recognized according to
+`eword-decode-ignored-field-list',
+`eword-decode-structured-field-list' and FIELD-NAME.
+
+Non MIME encoded-word part in FILED-BODY is decoded with
+`default-mime-charset'."
+ (if (symbolp field-name) (setq field-name (symbol-name field-name)))
+ (let ((decoded
+ (if unfolded
+ (let ((ew-ignore-76bytes-limit t))
+ (ew-decode-field
+ field-name (ew-lf-crlf-to-crlf field-body)))
+ (ew-decode-field
+ field-name (ew-lf-crlf-to-crlf field-body)))))
+ (if max-column
+ (setq decoded (ew-crlf-refold
+ decoded
+ (1+ (string-width field-name))
+ (if (eq max-column t) fill-column max-column)))
+ (setq decoded (ew-crlf-unfold decoded)))
+ (ew-crlf-to-lf decoded)))
+
(defun eword-decode-header (&optional code-conversion separator)
"Decode MIME encoded-words in header fields.
If CODE-CONVERSION is nil, it decodes only encoded-words. If it is
(cdr decoded)))))))
(defun eword-analyze-atom (string &optional must-unfold)
- (if (let ((enable-multibyte-characters nil))
- (string-match std11-atom-regexp string))
+ (if (string-match std11-atom-regexp (string-as-unibyte string))
(let ((end (match-end 0)))
(if (and eword-decode-sticked-encoded-word
(string-match eword-encoded-word-in-phrase-regexp