8 (defun ew-b-check (encoding encoded-text) (string-match ew-b-regexp encoded-text))
9 (defun ew-q-check (encoding encoded-text) (string-match ew-q-regexp encoded-text))
11 (defsubst ew-eword-p (str)
12 (and (string-match ew-anchored-encoded-word-regexp str)
13 (or ew-permit-null-encoded-text
14 (< (match-beginning 3) (match-end 3)))))
16 (defun ew-decode-eword (str)
17 (if (string-match ew-anchored-encoded-word-regexp str)
18 (let ((charset (match-string 1 str))
19 (encoding (match-string 2 str))
20 (encoded-text (match-string 3 str))
24 (if (or ew-permit-null-encoded-text
25 (< 0 (length encoded-text)))
26 (if (and (setq bdec (ew-byte-decoder encoding))
27 (setq cdec (ew-char-decoder charset)))
28 (if (or (null (setq bcheck (ew-byte-checker encoding)))
29 (funcall bcheck encoding encoded-text))
30 (ew-quote (closure-call cdec (funcall bdec encoded-text)))
32 (ew-quote-eword charset encoding encoded-text))
36 (defun ew-byte-decoder (encoding)
37 (cdr (assoc (upcase encoding) ew-byte-decoder-alist)))
39 (defun ew-byte-checker (encoding)
40 (cdr (assoc (upcase encoding) ew-byte-checker-alist)))
42 (defun ew-char-decoder (charset)
43 (let ((sym (intern (downcase charset))))
44 (when (mime-charset-to-coding-system sym 'LF)
46 (lambda (str) (decode-mime-charset-string str sym 'LF))