comparison lisp/gnus/qp.el @ 47944:03cfc305a0fa

(quoted-printable-encode-region): Use mm-insert-byte. Maybe use string-to-multibyte. Avoid find-charset-region. Cope with encoding Emacs 22 eight-bit chars.
author Dave Love <fx@gnu.org>
date Fri, 18 Oct 2002 10:43:12 +0000
parents 4f7c660e6029
children 695cf19ef79e d7ddb3e565de
comparison
equal deleted inserted replaced
47943:9f8c520b2a12 47944:03cfc305a0fa
1 ;;; qp.el --- Quoted-Printable functions 1 ;;; qp.el --- Quoted-Printable functions
2 2
3 ;; Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. 3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002 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.
64 (delete-char 2)) 64 (delete-char 2))
65 ((looking-at "=[0-9A-F][0-9A-F]") 65 ((looking-at "=[0-9A-F][0-9A-F]")
66 (let ((byte (string-to-int (buffer-substring (1+ (point)) 66 (let ((byte (string-to-int (buffer-substring (1+ (point))
67 (+ 3 (point))) 67 (+ 3 (point)))
68 16))) 68 16)))
69 (insert byte) 69 (mm-insert-byte byte 1)
70 (delete-char 3) 70 (delete-char 3)
71 (unless (eq byte ?=) 71 (unless (eq byte ?=)
72 (backward-char)))) 72 (backward-char))))
73 (t 73 (t
74 (error "Malformed quoted-printable text") 74 (error "Malformed quoted-printable text")
93 You should probably avoid non-ASCII characters in this arg. 93 You should probably avoid non-ASCII characters in this arg.
94 94
95 If `mm-use-ultra-safe-encoding' is set, fold lines unconditionally and 95 If `mm-use-ultra-safe-encoding' is set, fold lines unconditionally and
96 encode lines starting with \"From\"." 96 encode lines starting with \"From\"."
97 (interactive "r") 97 (interactive "r")
98 ;; Fixme: what should this do in XEmacs/Mule? 98 (save-excursion
99 (if (fboundp 'find-charset-region) ; else XEmacs, non-Mule 99 (goto-char from)
100 (if (delq 'unknown ; Emacs 20 unibyte 100 (if (fboundp 'string-to-multibyte) ; Emacs 22
101 (delq 'eight-bit-graphic ; Emacs 21 101 (if (re-search-forward (string-to-multibyte "[^\x0-\x7f\x80-\xff]")
102 (delq 'eight-bit-control 102 to t)
103 (delq 'ascii (find-charset-region from to))))) 103 ;; Fixme: This is somewhat misleading.
104 (error "Multibyte character in QP encoding region"))) 104 (error "Multibyte character in QP encoding region"))
105 (if (re-search-forward (mm-string-as-multibyte "[^\0-\377]") to t)
106 (error "Multibyte character in QP encoding region"))))
105 (unless class 107 (unless class
106 ;; Avoid using 8bit characters. = is \075. 108 ;; Avoid using 8bit characters. = is \075.
107 ;; Equivalent to "^\000-\007\013\015-\037\200-\377=" 109 ;; Equivalent to "^\000-\007\013\015-\037\200-\377="
108 (setq class "\010-\012\014\040-\074\076-\177")) 110 (setq class "\010-\012\014\040-\074\076-\177"))
109 (save-excursion 111 (save-excursion
113 (goto-char (point-min)) 115 (goto-char (point-min))
114 (while (and (skip-chars-forward class) 116 (while (and (skip-chars-forward class)
115 (not (eobp))) 117 (not (eobp)))
116 (insert 118 (insert
117 (prog1 119 (prog1
118 (format "=%02X" (char-after)) 120 ;; To unibyte in case of Emacs 22 eight-bit.
121 (format "=%02X" (mm-multibyte-char-to-unibyte (char-after)))
119 (delete-char 1)))) 122 (delete-char 1))))
120 ;; Encode white space at the end of lines. 123 ;; Encode white space at the end of lines.
121 (goto-char (point-min)) 124 (goto-char (point-min))
122 (while (re-search-forward "[ \t]+$" nil t) 125 (while (re-search-forward "[ \t]+$" nil t)
123 (goto-char (match-beginning 0)) 126 (goto-char (match-beginning 0))