+ (tm-eword::addresses-to-rwl (std11-parse-addresses-string str))
+ ))
+
+
+;;; @ application interfaces
+;;;
+
+(defun mime/encode-field (str)
+ (setq str (std11-unfold-string str))
+ (let ((ret (string-match std11-field-head-regexp str)))
+ (or (if ret
+ (let ((field-name (substring str 0 (1- (match-end 0))))
+ (field-body (eliminate-top-spaces
+ (substring str (match-end 0))))
+ fname)
+ (if (setq ret
+ (cond ((string-equal field-body "") "")
+ ((member (setq fname (downcase field-name))
+ '("reply-to" "from" "sender"
+ "resent-reply-to" "resent-from"
+ "resent-sender" "to" "resent-to"
+ "cc" "resent-cc"
+ "bcc" "resent-bcc" "dcc")
+ )
+ (car (tm-eword::encode-address-list
+ (+ (length field-name) 2) field-body))
+ )
+ (t
+ (catch 'tag
+ (let ((r mime/no-encoding-header-fields)
+ fn)
+ (while r
+ (setq fn (car r))
+ (if (string-equal (downcase fn) fname)
+ (throw 'tag field-body)
+ )
+ (setq r (cdr r))
+ ))
+ (car (tm-eword::encode-string
+ (+ (length field-name) 1)
+ field-body 'text))
+ ))
+ ))
+ (concat field-name ": " ret)
+ )))
+ (car (tm-eword::encode-string 0 str))
+ )))
+
+(defun mime/exist-encoded-word-in-subject ()
+ (let ((str (std11-field-body "Subject")))
+ (if (and str (string-match mime/encoded-word-regexp str))
+ str)))
+
+(defun mime/encode-message-header ()
+ (interactive "*")
+ (save-excursion
+ (save-restriction
+ (std11-narrow-to-header mail-header-separator)
+ (goto-char (point-min))
+ (let (beg end field)
+ (while (re-search-forward std11-field-head-regexp nil t)
+ (setq beg (match-beginning 0))
+ (setq end (std11-field-end))
+ (if (and (find-charset-region beg end)
+ (setq field
+ (mime/encode-field
+ (buffer-substring-no-properties beg end)
+ ))
+ )
+ (progn
+ (delete-region beg end)
+ (insert field)
+ ))
+ ))
+ (if mime/use-X-Nsubject
+ (let ((str (mime/exist-encoded-word-in-subject)))
+ (if str
+ (insert
+ (concat
+ "\nX-Nsubject: "
+ (mime-eword/decode-string (std11-unfold-string str))
+ )))))
+ )))
+
+(defun mime-eword/encode-string (str &optional column mode)
+ (car (tm-eword::encode-rwl (or column 0) (tm-eword::split-string str mode)))
+ )