;; Renamed: 1993/06/03 to tiny-mime.el
;; Renamed: 1995/10/03 from tiny-mime.el (split off encoder)
;; Renamed: 1997/02/22 from tm-ew-d.el
-;; Version: $Revision: 0.4 $
+;; Version: $Revision: 0.14 $
;; Keywords: encoded-word, MIME, multilingual, header, mail, news
;; This file is part of SEMI (SEMI is Emacs MIME Interfaces).
;;; Code:
-(require 'emu)
(require 'std11)
(require 'mel)
(require 'mime-def)
;;;
(defconst eword-decode-RCS-ID
- "$Id: eword-decode.el,v 0.4 1997-02-24 08:51:06 tmorioka Exp $")
+ "$Id: eword-decode.el,v 0.14 1997-02-27 08:56:45 tmorioka Exp $")
(defconst eword-decode-version (get-version-string eword-decode-RCS-ID))
(regexp-quote "?=")))
+;;; @@ Base64
+;;;
+
+(defconst base64-token-regexp "[A-Za-z0-9+/]")
+(defconst base64-token-padding-regexp "[A-Za-z0-9+/=]")
+
+(defconst eword-B-encoded-text-regexp
+ (concat "\\(\\("
+ base64-token-regexp
+ base64-token-regexp
+ base64-token-regexp
+ base64-token-regexp
+ "\\)*"
+ base64-token-regexp
+ base64-token-regexp
+ base64-token-padding-regexp
+ base64-token-padding-regexp
+ "\\)"))
+
+;; (defconst eword-B-encoding-and-encoded-text-regexp
+;; (concat "\\(B\\)\\?" eword-B-encoded-text-regexp))
+
+
+;;; @@ Quoted-Printable
+;;;
+
+(defconst quoted-printable-hex-chars "0123456789ABCDEF")
+(defconst quoted-printable-octet-regexp
+ (concat "=[" quoted-printable-hex-chars
+ "][" quoted-printable-hex-chars "]"))
+
+(defconst eword-Q-encoded-text-regexp
+ (concat "\\([^=?]\\|" quoted-printable-octet-regexp "\\)+"))
+;; (defconst eword-Q-encoding-and-encoded-text-regexp
+;; (concat "\\(Q\\)\\?" eword-Q-encoded-text-regexp))
+
+
;;; @ for string
;;;
(replace-match "\\1\\6")
(goto-char (point-min))
)
- (let (charset encoding text)
- (while (re-search-forward eword-encoded-word-regexp nil t)
- (insert (eword-decode-encoded-word
- (prog1
- (buffer-substring (match-beginning 0) (match-end 0))
- (delete-region (match-beginning 0) (match-end 0))
- ) must-unfold))
- ))
+ (while (re-search-forward eword-encoded-word-regexp nil t)
+ (insert (eword-decode-encoded-word
+ (prog1
+ (buffer-substring (match-beginning 0) (match-end 0))
+ (delete-region (match-beginning 0) (match-end 0))
+ ) must-unfold))
+ )
)))
;;; @ encoded-word decoder
;;;
+(defvar eword-warning-face nil "Face used for invalid encoded-word.")
+
(defun eword-decode-encoded-word (word &optional must-unfold)
"Decode WORD if it is an encoded-word.
(condition-case err
(eword-decode-encoded-text charset encoding text must-unfold)
(error
- (and (tl:add-text-properties 0 (length word)
- (and tm:warning-face
- (list 'face tm:warning-face))
- word)
- word)))
+ (and
+ (add-text-properties 0 (length word)
+ (and eword-warning-face
+ (list 'face eword-warning-face))
+ word)
+ word)))
))
word))