;;; mail-utils.el --- utility functions used both by rmail and rnews
-;; Copyright (C) 1985, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001, 2002, 2003, 2004,
+;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: mail, news
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
(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
((= (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
(provide 'mail-utils)
-;;; arch-tag: b24aec2f-fd65-4ceb-9e39-3cc2827036fd
+;; arch-tag: b24aec2f-fd65-4ceb-9e39-3cc2827036fd
;;; mail-utils.el ends here