Gnus development mailing list
 help / color / mirror / Atom feed
From: Reiner Steib <reinersteib+gmane@imap.cc>
To: Kenichi Handa <handa@ni.aist.go.jp>, <ding@gnus.org>,
	<emacs-devel@gnu.org>
Cc: topia@clovery.jp, Jason Rumney <jasonr@gnu.org>
Subject: imap.el: international/utf-7.el vs. gnus/utf7.el (was: 23.0.50; utf7-decode failed with non latin-1 charactor)
Date: Tue, 06 Nov 2007 20:53:08 +0100	[thread overview]
Message-ID: <v9prynjgm3.fsf_-_@marauder.physik.uni-ulm.de> (raw)
In-Reply-To: <E1IovyW-0001nS-4a@etlken.m17n.org> (Kenichi Handa's message of "Mon, 05 Nov 2007 16:02:20 +0900")

On Mon, Nov 05 2007, Kenichi Handa wrote:

> Jason Rumney <jasonr@gnu.org> writes:
>> Probably lisp/international/utf-7.el should be fixed, and the Gnus one
>> dropped.

Please keep in mind the we want to keep the Gnus versions in
Emacs/trunk (Gnus 5.13) and Gnus/trunk (aka No Gnus) in sync.  We want
to keep No Gnus compatible with Emacs 21+ (and XEmacs 21.4+).  So we
need to add some compatibility code.

> I think the right thing is to uncomment all codes for
> utf-7-map in utf-7.el, and modify gnus to use normal
> encode/decode-coding-region/string with utf-7-imap.
>
> I've just committed the former change.  

AFAIKS, `utf-7-encode' also accepts that FROM is a string, but it's
not documented.  Can we rely on this?  Could you document it, please?

> Could someone do the latter change?

A grep through Gnus' sources suggests that it only uses the functions
`utf7-encode' and `utf7-decode' in `imap.el'.

How about the following patch to gnus/utf7.el (untested)?  Could you
suggest a better test instead of `(<= 23 emacs-major-version)'?

Instead of -OLD and -NEW we should use more suitable names or include
the defuns directly.

--8<---------------cut here---------------start------------->8---
--- utf7.el	04 Aug 2007 20:36:34 +0200	1.12
+++ utf7.el	06 Nov 2007 20:42:08 +0100	
@@ -207,7 +207,7 @@
   (mm-decode-coding-region (point-min) (point-max) 'iso-8859-1)
   (mm-enable-multibyte))
 
-(defun utf7-encode (string &optional for-imap)
+(defun utf7-encode-OLD (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
@@ -215,7 +215,7 @@
       (utf7-encode-internal for-imap)
       (buffer-string))))
 
-(defun utf7-decode (string &optional for-imap)
+(defun utf7-decode-OLD (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
@@ -224,6 +224,31 @@
       (mm-enable-multibyte)
       (buffer-string))))
 
+(defun utf7-encode-NEW (string &optional for-imap)
+  (with-temp-buffer
+    ;; (utf-7-encode FROM TO IMAP)
+    ;;
+    ;; `utf-7-encode' also accepts that FROM is a string, but it's not
+    ;; documented.
+    (utf-7-encode string nil for-imap)
+    (buffer-string)))
+
+(defun utf7-decode-NEW (string &optional for-imap)
+  (with-temp-buffer
+    (insert string)
+    (goto-char (point-min))
+    ;; (utf-7-decode LEN IMAP)
+    (utf-7-decode (buffer-size) for-imap)
+    (buffer-string)))
+
+(if (and (require 'utf-7 nil t) ;; Additional test for XEmacs?
+	 (<= 23 emacs-major-version)) ;; A feature test would be better
+    (progn
+      (defalias 'utf7-encode 'utf7-encode-NEW)
+      (defalias 'utf7-decode 'utf7-decode-NEW))
+  (defalias 'utf7-encode 'utf7-encode-OLD)
+  (defalias 'utf7-decode 'utf7-decode-OLD))
+
 (provide 'utf7)
 
 ;;; arch-tag: 96078b55-85c7-4161-aed2-932c24b282c7
--8<---------------cut here---------------end--------------->8---

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

       reply	other threads:[~2007-11-06 19:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87k5p1ho29.wl%topia@clovery.jp>
     [not found] ` <472B1AD5.3090006@gnu.org>
     [not found]   ` <E1IovyW-0001nS-4a@etlken.m17n.org>
2007-11-06 19:53     ` Reiner Steib [this message]
2007-11-07  0:36       ` Kenichi Handa
2007-11-20 21:08         ` imap.el: international/utf-7.el vs. gnus/utf7.el Reiner Steib

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=v9prynjgm3.fsf_-_@marauder.physik.uni-ulm.de \
    --to=reinersteib+gmane@imap.cc \
    --cc=Reiner.Steib@gmx.de \
    --cc=ding@gnus.org \
    --cc=emacs-devel@gnu.org \
    --cc=handa@ni.aist.go.jp \
    --cc=jasonr@gnu.org \
    --cc=topia@clovery.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).