Mercurial > emacs
comparison lisp/gnus/qp.el @ 82951:0fde48feb604
Import Gnus 5.10 from the v5_10 branch of the Gnus repository.
author | Andreas Schwab <schwab@suse.de> |
---|---|
date | Thu, 22 Jul 2004 16:45:51 +0000 |
parents | 695cf19ef79e |
children | 18b52f2ea5dc cce1c0ee76ee |
comparison
equal
deleted
inserted
replaced
56503:8bbd2323fbf2 | 82951:0fde48feb604 |
---|---|
1 ;;; qp.el --- Quoted-Printable functions | 1 ;;; qp.el --- Quoted-Printable functions |
2 | 2 |
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | 5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
6 ;; Keywords: mail, extensions | 6 ;; Keywords: mail, extensions |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
30 ;;; Code: | 30 ;;; Code: |
31 | 31 |
32 (require 'mm-util) | 32 (require 'mm-util) |
33 (eval-when-compile (defvar mm-use-ultra-safe-encoding)) | 33 (eval-when-compile (defvar mm-use-ultra-safe-encoding)) |
34 | 34 |
35 ;;;###autoload | |
35 (defun quoted-printable-decode-region (from to &optional coding-system) | 36 (defun quoted-printable-decode-region (from to &optional coding-system) |
36 "Decode quoted-printable in the region between FROM and TO, per RFC 2045. | 37 "Decode quoted-printable in the region between FROM and TO, per RFC 2045. |
37 If CODING-SYSTEM is non-nil, decode bytes into characters with that | 38 If CODING-SYSTEM is non-nil, decode bytes into characters with that |
38 coding-system. | 39 coding-system. |
39 | 40 |
40 Interactively, you can supply the CODING-SYSTEM argument | 41 Interactively, you can supply the CODING-SYSTEM argument |
41 with \\[universal-coding-system-argument]." | 42 with \\[universal-coding-system-argument]. |
43 | |
44 The CODING-SYSTEM argument is a historical hangover and is deprecated. | |
45 QP encodes raw bytes and should be decoded into raw bytes. Decoding | |
46 them into characters should be done separately." | |
42 (interactive | 47 (interactive |
43 ;; Let the user determine the coding system with "C-x RET c". | 48 ;; Let the user determine the coding system with "C-x RET c". |
44 (list (region-beginning) (region-end) coding-system-for-read)) | 49 (list (region-beginning) (region-end) coding-system-for-read)) |
45 (unless (mm-coding-system-p coding-system) ; e.g. `ascii' from Gnus | 50 (unless (mm-coding-system-p coding-system) ; e.g. `ascii' from Gnus |
46 (setq coding-system nil)) | 51 (setq coding-system nil)) |
65 ((looking-at "=[0-9A-F][0-9A-F]") | 70 ((looking-at "=[0-9A-F][0-9A-F]") |
66 (let ((byte (string-to-int (buffer-substring (1+ (point)) | 71 (let ((byte (string-to-int (buffer-substring (1+ (point)) |
67 (+ 3 (point))) | 72 (+ 3 (point))) |
68 16))) | 73 16))) |
69 (mm-insert-byte byte 1) | 74 (mm-insert-byte byte 1) |
70 (delete-char 3) | 75 (delete-char 3))) |
71 (unless (eq byte ?=) | |
72 (backward-char)))) | |
73 (t | 76 (t |
74 (error "Malformed quoted-printable text") | 77 (message "Malformed quoted-printable text") |
75 (forward-char))))) | 78 (forward-char))))) |
76 (if coding-system | 79 (if coding-system |
77 (mm-decode-coding-region (point-min) (point-max) coding-system))))) | 80 (mm-decode-coding-region (point-min) (point-max) coding-system))))) |
78 | 81 |
79 (defun quoted-printable-decode-string (string &optional coding-system) | 82 (defun quoted-printable-decode-string (string &optional coding-system) |
80 "Decode the quoted-printable encoded STRING and return the result. | 83 "Decode the quoted-printable encoded STRING and return the result. |
81 If CODING-SYSTEM is non-nil, decode the region with coding-system." | 84 If CODING-SYSTEM is non-nil, decode the region with coding-system. |
82 (with-temp-buffer | 85 Use of CODING-SYSTEM is deprecated; this function should deal with |
86 raw bytes, and coding conversion should be done separately." | |
87 (mm-with-unibyte-buffer | |
83 (insert string) | 88 (insert string) |
84 (quoted-printable-decode-region (point-min) (point-max) coding-system) | 89 (quoted-printable-decode-region (point-min) (point-max) coding-system) |
85 (buffer-string))) | 90 (buffer-string))) |
86 | 91 |
87 (defun quoted-printable-encode-region (from to &optional fold class) | 92 (defun quoted-printable-encode-region (from to &optional fold class) |