From: keiichi Date: Fri, 5 Nov 1999 06:12:55 +0000 (+0000) Subject: (eword-encoded-word-regexp): Match with RFC-2231. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=3ac44efaee60e4a673e6242d7240fff595d1b1e2;p=elisp%2Fflim.git (eword-encoded-word-regexp): Match with RFC-2231. (eword-decode-region): Likewise. (eword-decode-encoded-word): Likewise. (eword-decode-encoded-text): Add new option parameter `language'. --- diff --git a/eword-decode.el b/eword-decode.el index dd46d32..7515c0f 100644 --- a/eword-decode.el +++ b/eword-decode.el @@ -61,6 +61,7 @@ "\\(" mime-charset-regexp "\\)" + "\\(\\*\\([^?]+\\)\\)?" (regexp-quote "?") "\\([BbQq]\\)" (regexp-quote "?") @@ -228,7 +229,7 @@ such as a version of Net$cape)." "\\(\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) @@ -538,19 +539,25 @@ as a version of Net$cape)." (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)) @@ -558,7 +565,7 @@ as a version of Net$cape)." ;;; (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. @@ -568,22 +575,28 @@ So you should write error-handling code if you don't want break by errors. 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