summaryrefslogtreecommitdiff
path: root/lisp/mail/mail-utils.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2004-03-04 17:02:13 +0000
committerRichard M. Stallman <rms@gnu.org>2004-03-04 17:02:13 +0000
commit926f20041fc4d5cdaa94737117a236be2744cd02 (patch)
treee9ee1551ccbf8d37e72f89a34634224436eed82f /lisp/mail/mail-utils.el
parent5bb54c616f442f29e9241bd920a15f8a4d5f0432 (diff)
downloademacs-926f20041fc4d5cdaa94737117a236be2744cd02.tar.gz
(mail-unquote-printable-region): New arg UNIBYTE.
Diffstat (limited to 'lisp/mail/mail-utils.el')
-rw-r--r--lisp/mail/mail-utils.el25
1 files changed, 16 insertions, 9 deletions
diff --git a/lisp/mail/mail-utils.el b/lisp/mail/mail-utils.el
index 96a57b38f07..aecc87cf178 100644
--- a/lisp/mail/mail-utils.el
+++ b/lisp/mail/mail-utils.el
@@ -108,11 +108,15 @@ we expect to find and remove the wrapper characters =?ISO-8859-1?Q?....?=."
(apply 'concat (nreverse (cons (substring string i) strings))))))
;;;###autoload
-(defun mail-unquote-printable-region (beg end &optional wrapper noerror)
+(defun mail-unquote-printable-region (beg end &optional wrapper noerror
+ unibyte)
"Undo the \"quoted printable\" encoding in buffer from BEG to END.
If the optional argument WRAPPER is non-nil,
we expect to find and remove the wrapper characters =?ISO-8859-1?Q?....?=.
-If NOERROR is non-nil, return t if successful."
+If NOERROR is non-nil, return t if successful.
+If UNIBYTE is non-nil, insert converted characters as unibyte.
+That is useful if you are going to character code decoding afterward,
+as Rmail does."
(interactive "r\nP")
(let (failed)
(save-match-data
@@ -131,13 +135,16 @@ If NOERROR is non-nil, return t if successful."
((= (char-after (match-beginning 1)) ?=)
(replace-match "="))
((match-beginning 2)
- (replace-match
- (make-string 1
- (+ (* 16 (mail-unquote-printable-hexdigit
- (char-after (match-beginning 2))))
- (mail-unquote-printable-hexdigit
- (char-after (1+ (match-beginning 2))))))
- t t))
+ (let ((char (+ (* 16 (mail-unquote-printable-hexdigit
+ (char-after (match-beginning 2))))
+ (mail-unquote-printable-hexdigit
+ (char-after (1+ (match-beginning 2)))))))
+ (if unibyte
+ (progn
+ (replace-match "")
+ ;; insert-char will insert this as unibyte,
+ (insert-char char 1))
+ (replace-match (make-string 1 char) t t))))
(noerror
(setq failed t))
(t