GNU bug report logs -
#25658
26.0.50; ELisp part in a mail isn't encoded properly
Previous Next
Reported by: Katsumi Yamaoka <yamaoka <at> jpl.org>
Date: Thu, 9 Feb 2017 02:37:02 UTC
Severity: normal
Found in version 26.0.50
Done: Katsumi Yamaoka <yamaoka <at> jpl.org>
Bug is archived. No further changes may be made.
Full log
Message #10 received at 25658 <at> debbugs.gnu.org (full text, mbox):
On Thu, 09 Feb 2017 11:35:50 +0900, Katsumi Yamaoka wrote:
> In a message draft, an ELisp part containing non-ASCII letters,
> like the following, is not encoded properly.
> <#part type="application/emacs-lisp" disposition=inline>
> (defun mm-shr (handle)
> ...
> ;; Remove "soft hyphens".
> (goto-char (point-min))
> (while (search-forward "" nil t)
> (replace-match "" t t))
> <#/part>
;; Note that "" is a soft hyphen.
What Gnus wants to do is:
(quoted-printable-encode-string
(encode-coding-string "" 'iso-8859-1))
=> "=AD"
However what is actually done is:
(with-temp-buffer
;; `mml-generate-mime-1' does:
(set-buffer-multibyte t)
(insert "")
;; `mm-encode-body' does:
(encode-coding-region (point-min) (point-max) 'iso-8859-1)
;; `mm-encode-buffer' does:
(quoted-printable-encode-region (point-min) (point-max))
(buffer-string))
=> "=3FFFAD"
Hmm.
(with-temp-buffer
(set-buffer-multibyte t)
(insert "")
(encode-coding-region (point-min) (point-max) 'iso-8859-1)
(append (buffer-string) nil))
=> (4194221)
This would probably be the multibyte version of:
(append (encode-coding-string "" 'iso-8859-1) nil)
=> (173)
Doesn't it mean we ought not to use `encode-coding-region'?
Anyway, I think what we should do here would be one of the
following two ways:
(with-temp-buffer
(set-buffer-multibyte t)
(insert "")
(encode-coding-region (point-min) (point-max) 'iso-8859-1)
(set-buffer-multibyte nil)
(quoted-printable-encode-region (point-min) (point-max))
(buffer-string))
=> "=AD"
I'm not sure whether (set-buffer-multibyte nil) above does not do
anything other than converting characters to the unibyte version
one by one. OTOH, this is what I often do:
(with-temp-buffer
(set-buffer-multibyte t)
(insert "")
(insert (prog1
(encode-coding-string (buffer-string) 'iso-8859-1)
(erase-buffer)
(set-buffer-multibyte nil)))
(quoted-printable-encode-region (point-min) (point-max))
(buffer-string))
=> "=AD"
Regards,
This bug report was last modified 8 years and 102 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.