diff options
author | Reiner Steib <Reiner.Steib@gmx.de> | 2007-11-20 21:06:35 +0000 |
---|---|---|
committer | Reiner Steib <Reiner.Steib@gmx.de> | 2007-11-20 21:06:35 +0000 |
commit | f21470efb688f33c9313d641c9b16f4f5da3146b (patch) | |
tree | 3dd3c3c751f5f684e196483ffc378e390b938c73 /lisp/gnus/utf7.el | |
parent | 2ea6167b2d96f61f2e1a3a988aa0ad48da074d02 (diff) | |
download | emacs-f21470efb688f33c9313d641c9b16f4f5da3146b.tar.gz |
(utf7-encode, utf7-decode): Use coding system
`utf-7'/`utf-7-imap' from utf-7.el' if available.
Diffstat (limited to 'lisp/gnus/utf7.el')
-rw-r--r-- | lisp/gnus/utf7.el | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lisp/gnus/utf7.el b/lisp/gnus/utf7.el index dbe749cad69..deba6d131e4 100644 --- a/lisp/gnus/utf7.el +++ b/lisp/gnus/utf7.el @@ -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) |