1 ;;; eword-decode.el --- RFC 2047 based encoded-word decoder for GNU Emacs
3 ;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
5 ;; Author: ENAMI Tsugutomo <enami@sys.ptg.sony.co.jp>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; TANAKA Akira <akr@jaist.ac.jp>
9 ;; Original: 1992/07/20 ENAMI Tsugutomo's `mime.el'.
10 ;; Renamed: 1993/06/03 to tiny-mime.el by MORIOKA Tomohiko
11 ;; Renamed: 1995/10/03 to tm-ew-d.el (split off encoder)
12 ;; by MORIOKA Tomohiko
13 ;; Renamed: 1997/02/22 from tm-ew-d.el by MORIOKA Tomohiko
14 ;; Keywords: encoded-word, MIME, multilingual, header, mail, news
16 ;; This file is part of FLIM (Faithful Library about Internet Message).
18 ;; This program is free software; you can redistribute it and/or
19 ;; modify it under the terms of the GNU General Public License as
20 ;; published by the Free Software Foundation; either version 2, or (at
21 ;; your option) any later version.
23 ;; This program is distributed in the hope that it will be useful, but
24 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
25 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 ;; General Public License for more details.
28 ;; You should have received a copy of the GNU General Public License
29 ;; along with GNU Emacs; see the file COPYING. If not, write to the
30 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
31 ;; Boston, MA 02111-1307, USA.
39 (eval-when-compile (require 'cl))
41 (defgroup eword-decode nil
42 "Encoded-word decoding"
45 (defcustom eword-max-size-to-decode 1000
46 "*Max size to decode header field."
48 :type '(choice (integer :tag "Limit (bytes)")
49 (const :tag "Don't limit" nil)))
52 ;;; @ MIME encoded-word definition
56 (defconst eword-encoded-text-regexp "[!->@-~]+")
58 (defconst eword-encoded-word-regexp
60 (concat (regexp-quote "=?")
68 eword-encoded-text-regexp
70 (regexp-quote "?="))))
77 (defun eword-decode-string (string &optional must-unfold)
78 "Decode MIME encoded-words in STRING.
80 STRING is unfolded before decoding.
82 If an encoded-word is broken or your emacs implementation can not
83 decode the charset included in it, it is not decoded.
85 If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even
86 if there are in decoded encoded-words (generated by bad manner MUA
87 such as a version of Net$cape)."
88 (setq string (std11-unfold-string string))
89 (let ((dest "")(ew nil)
91 (while (and (string-match eword-encoded-word-regexp string)
92 (setq beg (match-beginning 0)
98 (string-match "^[ \t]+$" (substring string 0 beg))
100 (setq dest (concat dest (substring string 0 beg)))
105 (eword-decode-encoded-word
106 (substring string beg end) must-unfold)
108 (setq string (substring string end))
114 (defun eword-decode-structured-field-body (string
115 &optional start-column max-column
117 (let ((tokens (eword-lexical-analyze string start 'must-unfold))
121 (setq token (car tokens))
122 (setq result (concat result (eword-decode-token token)))
123 (setq tokens (cdr tokens)))
126 (defun eword-decode-and-unfold-structured-field-body (string
131 "Decode and unfold STRING as structured field body.
132 It decodes non us-ascii characters in FULL-NAME encoded as
133 encoded-words or invalid \"raw\" string. \"Raw\" non us-ascii
134 characters are regarded as variable `default-mime-charset'.
136 If an encoded-word is broken or your emacs implementation can not
137 decode the charset included in it, it is not decoded."
138 (let ((tokens (eword-lexical-analyze string start 'must-unfold))
141 (let* ((token (car tokens))
143 (setq tokens (cdr tokens))
145 (if (eq type 'spaces)
147 (concat result (eword-decode-token token))
151 (defun eword-decode-and-fold-structured-field-body (string
155 (if (and eword-max-size-to-decode
156 (> (length string) eword-max-size-to-decode))
159 (setq max-column fill-column))
160 (let ((c start-column)
161 (tokens (eword-lexical-analyze string start 'must-unfold))
164 (while (and (setq token (car tokens))
165 (setq tokens (cdr tokens)))
166 (let* ((type (car token)))
167 (if (eq type 'spaces)
168 (let* ((next-token (car tokens))
169 (next-str (eword-decode-token next-token))
170 (next-len (string-width next-str))
171 (next-c (+ c next-len 1)))
172 (if (< next-c max-column)
173 (setq result (concat result " " next-str)
175 (setq result (concat result "\n " next-str)
177 (setq tokens (cdr tokens))
179 (let* ((str (eword-decode-token token)))
180 (setq result (concat result str)
181 c (+ c (string-width str)))
184 (concat result (eword-decode-token token))
187 (defun eword-decode-unstructured-field-body (string &optional start-column
190 (decode-mime-charset-string string default-mime-charset)))
192 (defun eword-decode-and-unfold-unstructured-field-body (string
193 &optional start-column
196 (decode-mime-charset-string (std11-unfold-string string)
197 default-mime-charset)
200 (defun eword-decode-unfolded-unstructured-field-body (string
201 &optional start-column
204 (decode-mime-charset-string string default-mime-charset)
211 (defun eword-decode-region (start end &optional unfolding must-unfold)
212 "Decode MIME encoded-words in region between START and END.
214 If UNFOLDING is not nil, it unfolds before decoding.
216 If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even
217 if there are in decoded encoded-words (generated by bad manner MUA
218 such as a version of Net$cape)."
222 (narrow-to-region start end)
224 (eword-decode-unfold)
226 (goto-char (point-min))
227 (while (re-search-forward (concat "\\(" eword-encoded-word-regexp "\\)"
229 "\\(" eword-encoded-word-regexp "\\)")
231 (replace-match "\\1\\6")
232 (goto-char (point-min))
234 (while (re-search-forward eword-encoded-word-regexp nil t)
235 (insert (eword-decode-encoded-word
237 (buffer-substring (match-beginning 0) (match-end 0))
238 (delete-region (match-beginning 0) (match-end 0))
243 (defun eword-decode-unfold ()
244 (goto-char (point-min))
246 (while (re-search-forward std11-field-head-regexp nil t)
247 (setq beg (match-beginning 0)
248 end (std11-field-end))
249 (setq field (buffer-substring beg end))
250 (if (string-match eword-encoded-word-regexp field)
252 (narrow-to-region (goto-char beg) end)
253 (while (re-search-forward "\n\\([ \t]\\)" nil t)
254 (replace-match (match-string 1))
256 (goto-char (point-max))
261 ;;; @ for message header
264 (defvar mime-field-decoder-alist nil)
266 (defvar mime-field-decoder-cache nil)
268 (defvar mime-update-field-decoder-cache 'ew-mime-update-field-decoder-cache
269 "*Field decoder cache update function.")
271 (defun ew-mime-update-field-decoder-cache (field mode)
275 (lexical-let ((field-name (symbol-name field)))
276 (lambda (field-body &optional start-column max-column must-unfold)
277 (setq field-body (ew-lf-to-crlf field-body))
278 (let ((res (ew-crlf-to-lf
279 (ew-decode-field field-name field-body))))
282 (list 'original-field-name field-name
283 'original-field-body field-body)
287 (lexical-let ((field-name (symbol-name field)))
288 (lambda (field-body &optional start-column max-column must-unfold)
289 (setq field-body (ew-lf-to-crlf field-body))
290 (let* ((res (ew-decode-field field-name field-body))
291 (res (if (string= res field-body)
295 (or max-column fill-column))))
296 (res (ew-crlf-to-lf res)))
299 (list 'original-field-name field-name
300 'original-field-body field-body)
304 (lexical-let ((field-name (symbol-name field)))
305 (lambda (field-body &optional start-column max-column must-unfold)
306 (setq field-body (ew-lf-to-crlf field-body))
307 (let ((res (ew-crlf-to-lf
309 (ew-decode-field field-name field-body)))))
312 (list 'original-field-name field-name
313 'original-field-body field-body)
317 (lexical-let ((field-name (symbol-name field)))
318 (lambda (field-body &optional start-column max-column must-unfold)
319 (setq field-body (ew-lf-to-crlf field-body))
321 (let ((ew-ignore-76bytes-limit t))
322 (let ((res (ew-crlf-to-lf
324 (ew-decode-field field-name field-body)))))
327 (list 'original-field-name field-name
328 'original-field-body field-body)
333 (mime-update-field-decoder-cache field mode fun)))
336 (defun mime-set-field-decoder (field &rest specs)
337 "Set decoder of FILED.
338 SPECS must be like `MODE1 DECODER1 MODE2 DECODER2 ...'.
339 Each mode must be `nil', `plain', `wide', `summary' or `nov'.
340 If mode is `nil', corresponding decoder is set up for every modes."
342 (let ((mode (pop specs))
343 (function (pop specs)))
346 (let ((cell (assq mode mime-field-decoder-alist)))
348 (setcdr cell (put-alist field function (cdr cell)))
349 (setq mime-field-decoder-alist
350 (cons (cons mode (list (cons field function)))
351 mime-field-decoder-alist))
353 (apply (function mime-set-field-decoder) field specs)
355 (mime-set-field-decoder field
363 (defmacro mime-find-field-presentation-method (name)
364 "Return field-presentation-method from NAME.
365 NAME must be `plain', `wide', `summary' or `nov'."
367 `(or (assq 'summary mime-field-decoder-cache)
373 (symbolp (car (cdr name)))
374 (null (cdr (cdr name))))
375 `(or (assq ,name mime-field-decoder-cache)
379 `(or (assq (or ,name 'summary) mime-field-decoder-cache)
380 (cons (or ,name 'summary) nil))
383 (defun mime-find-field-decoder-internal (field &optional mode)
384 "Return function to decode field-body of FIELD in MODE.
385 Optional argument MODE must be object of field-presentation-method."
386 (cdr (or (assq field (cdr mode))
388 (funcall mime-update-field-decoder-cache
391 (cdr (assq (car mode) mime-field-decoder-cache)))
395 (defun mime-find-field-decoder (field &optional mode)
396 "Return function to decode field-body of FIELD in MODE.
397 Optional argument MODE must be object or name of
398 field-presentation-method. Name of field-presentation-method must be
399 `plain', `wide', `summary' or `nov'.
400 Default value of MODE is `summary'."
402 (let ((p (cdr (mime-find-field-presentation-method mode))))
403 (if (and p (setq p (assq field p)))
405 (cdr (funcall mime-update-field-decoder-cache
406 field (or mode 'summary)))))
407 (inline (mime-find-field-decoder-internal field mode))
411 (defun mime-update-field-decoder-cache (field mode &optional function)
412 "Update field decoder cache `mime-field-decoder-cache'."
413 (cond ((eq function 'identity)
418 (cdr (assq (or mode 'summary) mime-field-decoder-alist))))
419 (setq function (cdr (or (assq field decoder-alist)
420 (assq t decoder-alist)))))
422 (let ((cell (assq mode mime-field-decoder-cache))
425 (if (setq ret (assq field (cdr cell)))
426 (setcdr ret function)
427 (setcdr cell (cons (setq ret (cons field function)) (cdr cell))))
428 (setq mime-field-decoder-cache
429 (cons (cons mode (list (setq ret (cons field function))))
430 mime-field-decoder-cache)))
434 (mime-set-field-decoder 'Archive nil nil)
435 (mime-set-field-decoder 'Content-Md5 nil nil)
436 (mime-set-field-decoder 'Control nil nil)
437 (mime-set-field-decoder 'Date nil nil)
438 (mime-set-field-decoder 'Distribution nil nil)
439 (mime-set-field-decoder 'Followup-Host nil nil)
440 (mime-set-field-decoder 'Followup-To nil nil)
441 (mime-set-field-decoder 'Lines nil nil)
442 (mime-set-field-decoder 'Message-Id nil nil)
443 (mime-set-field-decoder 'Newsgroups nil nil)
444 (mime-set-field-decoder 'Nntp-Posting-Host nil nil)
445 (mime-set-field-decoder 'Path nil nil)
446 (mime-set-field-decoder 'Posted-And-Mailed nil nil)
447 (mime-set-field-decoder 'Received nil nil)
448 (mime-set-field-decoder 'Status nil nil)
449 (mime-set-field-decoder 'X-Face nil nil)
450 (mime-set-field-decoder 'X-Face-Version nil nil)
451 (mime-set-field-decoder 'X-Info nil nil)
452 (mime-set-field-decoder 'X-Pgp-Key-Info nil nil)
453 (mime-set-field-decoder 'X-Pgp-Sig nil nil)
454 (mime-set-field-decoder 'X-Pgp-Sig-Version nil nil)
455 (mime-set-field-decoder 'Xref nil nil)
459 '(Reply-To Resent-Reply-To From Resent-From Sender Resent-Sender
460 To Resent-To Cc Resent-Cc Bcc Resent-Bcc Dcc
462 Mime-Version Content-Type Content-Transfer-Encoding
463 Content-Disposition User-Agent))
466 (setq field (pop fields))
467 (mime-set-field-decoder
469 'plain #'eword-decode-structured-field-body
470 'wide #'eword-decode-and-fold-structured-field-body
471 'summary #'eword-decode-and-unfold-structured-field-body
472 'nov #'eword-decode-and-unfold-structured-field-body)
475 ;; unstructured fields (default)
476 (mime-set-field-decoder
478 'plain #'eword-decode-unstructured-field-body
479 'wide #'eword-decode-unstructured-field-body
480 'summary #'eword-decode-and-unfold-unstructured-field-body
481 'nov #'eword-decode-unfolded-unstructured-field-body)
484 (defun mime-decode-field-body (field-body field-name
485 &optional mode max-column)
486 "Decode FIELD-BODY as FIELD-NAME in MODE, and return the result.
487 Optional argument MODE must be `plain', `wide', `summary' or `nov'.
488 Default mode is `summary'.
490 If MODE is `wide' and MAX-COLUMN is non-nil, the result is folded with
493 Non MIME encoded-word part in FILED-BODY is decoded with
494 `default-mime-charset'."
495 (unless mode (setq mode 'summary))
496 (if (symbolp field-name) (setq field-name (symbol-name field-name)))
499 (let ((ew-ignore-76bytes-limit t))
501 field-name (ew-lf-crlf-to-crlf field-body)))
503 field-name (ew-lf-crlf-to-crlf field-body)))))
504 (if (and (eq mode 'wide) max-column)
505 (setq decoded (ew-crlf-refold
507 (1+ (string-width field-name))
509 (if (not (eq mode 'plain))
510 (setq decoded (ew-crlf-unfold decoded))))
511 (setq decoded (ew-crlf-to-lf decoded))
512 (add-text-properties 0 (length decoded)
513 (list 'original-field-name field-name
514 'original-field-body field-body)
519 (defun mime-decode-header-in-region (start end
520 &optional code-conversion)
521 "Decode MIME encoded-words in region between START and END.
522 If CODE-CONVERSION is nil, it decodes only encoded-words. If it is
523 mime-charset, it decodes non-ASCII bit patterns as the mime-charset.
524 Otherwise it decodes non-ASCII bit patterns as the
525 default-mime-charset."
529 (narrow-to-region start end)
530 (let ((default-charset
532 (if (mime-charset-to-coding-system code-conversion)
534 default-mime-charset))))
536 (let ((mode-obj (mime-find-field-presentation-method 'wide))
537 beg p end field-name len field-decoder)
538 (goto-char (point-min))
539 (while (re-search-forward std11-field-head-regexp nil t)
540 (setq beg (match-beginning 0)
542 field-name (buffer-substring beg (1- p))
543 len (string-width field-name)
544 field-decoder (inline
545 (mime-find-field-decoder-internal
546 (intern (capitalize field-name))
549 (setq end (std11-field-end))
550 (let ((body (buffer-substring p end))
551 (default-mime-charset default-charset))
552 (delete-region p end)
553 (insert (funcall field-decoder body (1+ len)))
554 (add-text-properties beg (min (1+ (point)) (point-max))
555 (list 'original-field-name field-name
556 'original-field-body field-body))
559 (eword-decode-region (point-min) (point-max) t)
563 (defun mime-decode-header-in-buffer (&optional code-conversion separator)
564 "Decode MIME encoded-words in header fields.
565 If CODE-CONVERSION is nil, it decodes only encoded-words. If it is
566 mime-charset, it decodes non-ASCII bit patterns as the mime-charset.
567 Otherwise it decodes non-ASCII bit patterns as the
568 default-mime-charset.
569 If SEPARATOR is not nil, it is used as header separator."
571 (mime-decode-header-in-region
574 (goto-char (point-min))
575 (if (re-search-forward
576 (concat "^\\(" (regexp-quote (or separator "")) "\\)?$")
583 (define-obsolete-function-alias 'eword-decode-header
584 'mime-decode-header-in-buffer)
587 ;;; @ encoded-word decoder
590 (defvar eword-decode-encoded-word-error-handler
591 'eword-decode-encoded-word-default-error-handler)
593 (defvar eword-warning-face nil
594 "Face used for invalid encoded-word.")
596 (defun eword-decode-encoded-word-default-error-handler (word signal)
597 (and (add-text-properties 0 (length word)
598 (and eword-warning-face
599 (list 'face eword-warning-face))
603 (defun eword-decode-encoded-word (word &optional must-unfold)
604 "Decode WORD if it is an encoded-word.
606 If your emacs implementation can not decode the charset of WORD, it
607 returns WORD. Similarly the encoded-word is broken, it returns WORD.
609 If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even
610 if there are in decoded encoded-word (generated by bad manner MUA such
611 as a version of Net$cape)."
612 (or (if (string-match eword-encoded-word-regexp word)
614 (substring word (match-beginning 1) (match-end 1))
618 (substring word (match-beginning 2) (match-end 2))
621 (substring word (match-beginning 3) (match-end 3))
624 (eword-decode-encoded-text charset encoding text must-unfold)
626 (funcall eword-decode-encoded-word-error-handler word err)
632 ;;; @ encoded-text decoder
635 (defun eword-decode-encoded-text (charset encoding string
636 &optional must-unfold)
637 "Decode STRING as an encoded-text.
639 If your emacs implementation can not decode CHARSET, it returns nil.
641 If ENCODING is not \"B\" or \"Q\", it occurs error.
642 So you should write error-handling code if you don't want break by errors.
644 If MUST-UNFOLD is non-nil, it unfolds and eliminates line-breaks even
645 if there are in decoded encoded-text (generated by bad manner MUA such
646 as a version of Net$cape)."
647 (let ((cs (mime-charset-to-coding-system charset)))
649 (let ((dest (encoded-text-decode-string string encoding)))
651 (setq dest (decode-mime-charset-string dest charset))
655 (cond ((eq chr ?\n) "")
657 (t (char-to-string chr)))
659 (std11-unfold-string dest)
664 ;;; @ lexical analyze
667 (defvar eword-lexical-analyze-cache nil)
668 (defvar eword-lexical-analyze-cache-max 299
669 "*Max position of eword-lexical-analyze-cache.
670 It is max size of eword-lexical-analyze-cache - 1.")
672 (defcustom eword-lexical-analyzer
673 '(eword-analyze-quoted-string
674 eword-analyze-domain-literal
675 eword-analyze-comment
677 eword-analyze-special
678 eword-analyze-encoded-word
680 "*List of functions to return result of lexical analyze.
681 Each function must have three arguments: STRING, START and MUST-UNFOLD.
682 STRING is the target string to be analyzed.
683 START is start position of STRING to analyze.
684 If MUST-UNFOLD is not nil, each function must unfold and eliminate
685 bare-CR and bare-LF from the result even if they are included in
686 content of the encoded-word.
687 Each function must return nil if it can not analyze STRING as its
690 Previous function is preferred to next function. If a function
691 returns nil, next function is used. Otherwise the return value will
694 :type '(repeat function))
696 (defun eword-analyze-quoted-string-without-encoded-word (string start &optional must-unfold)
697 (let ((p (std11-check-enclosure string ?\" ?\" nil start)))
699 (cons (cons 'quoted-string
700 (decode-mime-charset-string
701 (std11-strip-quoted-pair
702 (substring string (1+ start) (1- p)))
703 default-mime-charset))
704 ;;(substring string p))
708 (defun eword-analyze-quoted-string-with-encoded-word (string start &optional must-unfold)
709 (let ((p (std11-check-enclosure string ?\" ?\" nil start)))
711 (cons (cons 'quoted-string
713 (std11-strip-quoted-pair
714 (substring string (1+ start) (1- p)))))
715 (if (string-match eword-encoded-word-regexp str)
716 (eword-decode-encoded-word str)
717 (decode-mime-charset-string str default-mime-charset)
722 (defvar eword-analyze-quoted-encoded-word nil)
723 (defun eword-analyze-quoted-string (string start &optional must-unfold)
724 (if eword-analyze-quoted-encoded-word
725 (eword-analyze-quoted-string-with-encoded-word string start must-unfold)
726 (eword-analyze-quoted-string-without-encoded-word string start must-unfold)))
728 (defun eword-analyze-domain-literal (string start &optional must-unfold)
729 (std11-analyze-domain-literal string start))
731 (defun eword-analyze-comment (string from &optional must-unfold)
732 (let ((len (length string))
737 (eq (aref string i) ?\())
742 (setq chr (aref string i))
748 (setq last-str (concat last-str
749 (substring string from (1- i))
750 (char-to-string (aref string i)))
755 (setq ret (concat last-str
756 (substring string from i)))
764 (decode-mime-charset-string
765 ret default-mime-charset)
772 (if (setq ret (eword-analyze-comment string i must-unfold))
775 (substring string from i))
777 (if (string= last-str "")
778 (cons (car ret) dest)
781 (decode-mime-charset-string
782 last-str default-mime-charset)
796 (defun eword-analyze-spaces (string start &optional must-unfold)
797 (std11-analyze-spaces string start))
799 (defun eword-analyze-special (string start &optional must-unfold)
800 (std11-analyze-special string start))
802 (defun eword-analyze-encoded-word (string start &optional must-unfold)
803 (if (and (string-match eword-encoded-word-regexp string start)
804 (= (match-beginning 0) start))
805 (let ((end (match-end 0))
806 (dest (eword-decode-encoded-word (match-string 0 string)
809 ;;(setq string (substring string end))
811 (while (and (string-match (eval-when-compile
812 (concat "[ \t\n]*\\("
813 eword-encoded-word-regexp
816 (= (match-beginning 0) start))
817 (setq end (match-end 0))
820 (eword-decode-encoded-word (match-string 1 string)
822 ;;string (substring string end))
825 (cons (cons 'atom dest) ;;string)
829 (defun eword-analyze-atom (string start &optional must-unfold)
830 (if (and (string-match std11-atom-regexp string start)
831 (= (match-beginning 0) start))
832 (let ((end (match-end 0)))
833 (cons (cons 'atom (decode-mime-charset-string
834 (substring string start end)
835 default-mime-charset))
836 ;;(substring string end)
840 (defun eword-lexical-analyze-internal (string start must-unfold)
841 (let ((len (length string))
845 (let ((rest eword-lexical-analyzer)
847 (while (and (setq func (car rest))
849 (setq r (funcall func string start must-unfold)))
851 (setq rest (cdr rest)))
853 (list (cons 'error (substring string start)) (1+ len)))
855 (setq dest (cons (car ret) dest)
861 (defun eword-lexical-analyze (string &optional start must-unfold)
862 "Return lexical analyzed list corresponding STRING.
863 It is like std11-lexical-analyze, but it decodes non us-ascii
864 characters encoded as encoded-words or invalid \"raw\" format.
865 \"Raw\" non us-ascii characters are regarded as variable
866 `default-mime-charset'."
867 (let ((key (substring string (or start 0)))
869 (set-text-properties 0 (length key) nil key)
870 (if (setq ret (assoc key eword-lexical-analyze-cache))
872 (setq ret (eword-lexical-analyze-internal key 0 must-unfold))
873 (setq eword-lexical-analyze-cache
875 eword-lexical-analyze-cache))
876 (if (cdr (setq cell (nthcdr eword-lexical-analyze-cache-max
877 eword-lexical-analyze-cache)))
881 (defun eword-decode-token (token)
882 (let ((type (car token))
884 (cond ((eq type 'quoted-string)
885 (std11-wrap-as-quoted-string value))
889 (setq dest (concat dest
890 (if (stringp (car value))
891 (std11-wrap-as-quoted-pairs
892 (car value) '(?( ?)))
893 (eword-decode-token (car value))
897 (concat "(" dest ")")
901 (defun eword-extract-address-components (string &optional start)
902 "Extract full name and canonical address from STRING.
903 Returns a list of the form (FULL-NAME CANONICAL-ADDRESS).
904 If no name can be extracted, FULL-NAME will be nil.
905 It decodes non us-ascii characters in FULL-NAME encoded as
906 encoded-words or invalid \"raw\" string. \"Raw\" non us-ascii
907 characters are regarded as variable `default-mime-charset'."
908 (let* ((structure (car (std11-parse-address
909 (eword-lexical-analyze
910 (std11-unfold-string string) start
912 (phrase (std11-full-name-string structure))
913 (address (std11-address-string structure))
915 (list phrase address)
922 (provide 'eword-decode)
924 ;;; eword-decode.el ends here