1 ;;; qp.el --- Quoted-Printable functions
3 ;; Copyright (C) 1998-2014 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: mail, extensions
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; Functions for encoding and decoding quoted-printable text as
26 ;; defined in RFC 2045.
31 (defvar mm-use-ultra-safe-encoding)
34 (defun quoted-printable-decode-region (from to &optional coding-system)
35 "Decode quoted-printable in the region between FROM and TO, per RFC 2045.
36 If CODING-SYSTEM is non-nil, decode bytes into characters with that
39 Interactively, you can supply the CODING-SYSTEM argument
40 with \\[universal-coding-system-argument].
42 The CODING-SYSTEM argument is a historical hangover and is deprecated.
43 QP encodes raw bytes and should be decoded into raw bytes. Decoding
44 them into characters should be done separately."
46 ;; Let the user determine the coding system with "C-x RET c".
47 (list (region-beginning) (region-end) coding-system-for-read))
48 (unless (mm-coding-system-p coding-system) ; e.g. `ascii' from Gnus
49 (setq coding-system nil))
52 ;; RFC 2045: ``An "=" followed by two hexadecimal digits, one
53 ;; or both of which are lowercase letters in "abcdef", is
54 ;; formally illegal. A robust implementation might choose to
55 ;; recognize them as the corresponding uppercase letters.''
56 (let ((case-fold-search t))
57 (narrow-to-region from to)
58 ;; Do this in case we're called from Gnus, say, in a buffer