]> git.eshelyaron.com Git - emacs.git/commitdiff
(utf7-encode, utf7-decode): Use coding system
authorReiner Steib <Reiner.Steib@gmx.de>
Tue, 20 Nov 2007 21:06:35 +0000 (21:06 +0000)
committerReiner Steib <Reiner.Steib@gmx.de>
Tue, 20 Nov 2007 21:06:35 +0000 (21:06 +0000)
`utf-7'/`utf-7-imap' from utf-7.el' if available.

lisp/gnus/ChangeLog
lisp/gnus/utf7.el

index c67eece640a8ec0d6c6a742474f8c5964cf6e984..dd8b059c55d88ebe3286476aa9e16ee2a17b0dd1 100644 (file)
@@ -1,5 +1,8 @@
 2007-11-20  Reiner Steib  <Reiner.Steib@gmx.de>
 
+       * utf7.el (utf7-encode, utf7-decode): Use coding system
+       `utf-7'/`utf-7-imap' from utf-7.el' if available.
+
        * message.el (message-send-mail-function): New function.
        (message-send-mail-function): Set default using
        message-send-mail-function.  Adjust doc string.
index dbe749cad690fbffa286fb5beee5a6ae62743565..deba6d131e4c5aaf35a6a6cc117cfabc15c0c226 100644 (file)
@@ -209,20 +209,26 @@ Characters are in raw byte pairs in narrowed buffer."
 
 (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))
+    (let ((default-enable-multibyte-characters t))
+      (with-temp-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."
-  (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))
+    (let ((default-enable-multibyte-characters nil))
+      (with-temp-buffer
+       (insert string)
+       (utf7-decode-internal for-imap)
+       (mm-enable-multibyte)
+       (buffer-string)))))
 
 (provide 'utf7)