projects
/
gnus
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(shr-tag-li): Get <li> indentation right.
[gnus]
/
lisp
/
utf7.el
diff --git
a/lisp/utf7.el
b/lisp/utf7.el
index
8c76160
..
47c3b0f
100644
(file)
--- a/
lisp/utf7.el
+++ b/
lisp/utf7.el
@@
-1,7
+1,7
@@
;;; utf7.el --- UTF-7 encoding/decoding for Emacs -*-coding: iso-8859-1;-*-
;;; utf7.el --- UTF-7 encoding/decoding for Emacs -*-coding: iso-8859-1;-*-
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
-;; 200
5, 2006
Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006, 2007,
+;; 200
8, 2009, 2010
Free Software Foundation, Inc.
;; Author: Jon K Hellan <hellan@acm.org>
;; Maintainer: bugs@gnus.org
;; Author: Jon K Hellan <hellan@acm.org>
;; Maintainer: bugs@gnus.org
@@
-9,10
+9,10
@@
;; This file is part of GNU Emacs.
;; 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
;; 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 Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-20,9
+20,7
@@
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; 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., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Commentary:
@@
-80,7
+78,7
@@
(defconst utf7-utf-16-coding-system
(cond ((mm-coding-system-p 'utf-16-be-no-signature) ; Mule-UCS
'utf-16-be-no-signature)
(defconst utf7-utf-16-coding-system
(cond ((mm-coding-system-p 'utf-16-be-no-signature) ; Mule-UCS
'utf-16-be-no-signature)
- ((and (mm-coding-system-p 'utf-16-be) ; Emacs
21.3, Emacs 22
+ ((and (mm-coding-system-p 'utf-16-be) ; Emacs
;; Avoid versions with BOM.
(= 2 (length (encode-coding-string "a" 'utf-16-be))))
'utf-16-be)
;; Avoid versions with BOM.
(= 2 (length (encode-coding-string "a" 'utf-16-be))))
'utf-16-be)
@@
-114,7
+112,7
@@
Use IMAP modification if FOR-IMAP is non-nil."
(skip-chars-forward not-direct-encoding-chars)))
(if (and (= fc esc-char)
(= run-length 1)) ; Lone esc-char?
(skip-chars-forward not-direct-encoding-chars)))
(if (and (= fc esc-char)
(= run-length 1)) ; Lone esc-char?
- (delete-
backward-char 1)
; Now there's one too many
+ (delete-
char -1)
; Now there's one too many
(utf7-fragment-encode p (point) for-imap))
(insert "-")))))))
(utf7-fragment-encode p (point) for-imap))
(insert "-")))))))
@@
-155,7
+153,7
@@
Use IMAP modification if FOR-IMAP is non-nil."
(save-excursion
(utf7-fragment-decode p (point) for-imap)
(goto-char p)
(save-excursion
(utf7-fragment-decode p (point) for-imap)
(goto-char p)
- (delete-
backward-char
1)))))))))
+ (delete-
char -
1)))))))))
(defun utf7-fragment-decode (start end &optional for-imap)
"Decode base64 encoded fragment from START to END of UTF-7 text in buffer.
(defun utf7-fragment-decode (start end &optional for-imap)
"Decode base64 encoded fragment from START to END of UTF-7 text in buffer.
@@
-207,24
+205,28
@@
Characters are in raw byte pairs in narrowed buffer."
(mm-decode-coding-region (point-min) (point-max) 'iso-8859-1)
(mm-enable-multibyte))
(mm-decode-coding-region (point-min) (point-max) 'iso-8859-1)
(mm-enable-multibyte))
+;;;###autoload
(defun utf7-encode (string &optional for-imap)
"Encode UTF-7 STRING. Use IMAP modification if FOR-IMAP is non-nil."
(defun utf7-encode (string &optional for-imap)
"Encode UTF-7 STRING. Use IMAP modification if FOR-IMAP is non-nil."
- (let ((default-enable-multibyte-characters t))
- (with-temp-buffer
- (insert string)
- (utf7-encode-internal for-imap)
- (buffer-string))))
+ (if (and (coding-system-p 'utf-7) (coding-system-p 'utf-7-imap))
+ ;; Emacs 23 with proper support for IMAP
+ (encode-coding-string string (if for-imap 'utf-7-imap 'utf-7))
+ (mm-with-multibyte-buffer
+ (insert string)
+ (utf7-encode-internal for-imap)
+ (buffer-string))))
(defun utf7-decode (string &optional for-imap)
"Decode UTF-7 STRING. Use IMAP modification if FOR-IMAP is non-nil."
(defun utf7-decode (string &optional for-imap)
"Decode UTF-7 STRING. Use IMAP modification if FOR-IMAP is non-nil."
- (let ((default-enable-multibyte-characters nil))
- (with-temp-buffer
- (insert string)
- (utf7-decode-internal for-imap)
- (mm-enable-multibyte)
- (buffer-string))))
+ (if (and (coding-system-p 'utf-7) (coding-system-p 'utf-7-imap))
+ ;; Emacs 23 with proper support for IMAP
+ (decode-coding-string string (if for-imap 'utf-7-imap 'utf-7))
+ (mm-with-unibyte-buffer
+ (insert string)
+ (utf7-decode-internal for-imap)
+ (mm-enable-multibyte)
+ (buffer-string))))
(provide 'utf7)
(provide 'utf7)
-;;; arch-tag: 96078b55-85c7-4161-aed2-932c24b282c7
;;; utf7.el ends here
;;; utf7.el ends here