From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Katsumi Yamaoka Newsgroups: gmane.emacs.bugs Subject: bug#25658: 26.0.50; ELisp part in a mail isn't encoded properly Date: Fri, 10 Feb 2017 09:56:47 +0900 Organization: Emacsen advocacy group Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1486688235 25993 195.159.176.226 (10 Feb 2017 00:57:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 10 Feb 2017 00:57:15 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (i686-pc-cygwin) To: 25658@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Feb 10 01:57:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbzWN-0006NR-Eh for geb-bug-gnu-emacs@m.gmane.org; Fri, 10 Feb 2017 01:57:07 +0100 Original-Received: from localhost ([::1]:41114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbzWT-00006J-4W for geb-bug-gnu-emacs@m.gmane.org; Thu, 09 Feb 2017 19:57:13 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbzWL-0008Ub-G2 for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2017 19:57:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbzWI-0006rn-99 for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2017 19:57:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35412) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cbzWI-0006rj-54 for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2017 19:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cbzWH-0007an-Qu for bug-gnu-emacs@gnu.org; Thu, 09 Feb 2017 19:57:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Katsumi Yamaoka Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Feb 2017 00:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25658 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25658-submit@debbugs.gnu.org id=B25658.148668822029177 (code B ref 25658); Fri, 10 Feb 2017 00:57:01 +0000 Original-Received: (at 25658) by debbugs.gnu.org; 10 Feb 2017 00:57:00 +0000 Original-Received: from localhost ([127.0.0.1]:33611 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbzWF-0007aX-RA for submit@debbugs.gnu.org; Thu, 09 Feb 2017 19:57:00 -0500 Original-Received: from mail-hampton.hostforweb.net ([205.234.186.191]:52600 helo=hampton.hostforweb.net) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbzWE-0007aI-Dl for 25658@debbugs.gnu.org; Thu, 09 Feb 2017 19:56:58 -0500 Original-Received: from s70.gtokyofl21.vectant.ne.jp ([202.215.75.70]:60000 helo=localhost) by hampton.hostforweb.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1cbzW6-000ACz-Cr; Thu, 09 Feb 2017 18:56:51 -0600 X-Face: #kKnN,xUnmKia.'[pp`; Omh}odZK)?7wQSl"4o04=EixTF+V[""w~iNbM9ZL+.b*_CxUmFk B#Fu[*?MZZH@IkN:!"\w%I_zt>[$nm7nQosZ<3eu; B:$Q_:p!',P.c0-_Cy[dz4oIpw0ESA^D*1Lw= L&i*6&( Cancel-Lock: sha1:d9dI9vqdfGwFtZ+M2FoaSyOryV4= X-OutGoing-Spam-Status: No, score=-2.9 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hampton.hostforweb.net X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - jpl.org X-Get-Message-Sender-Via: hampton.hostforweb.net: authenticated_id: yamaoka/from_h X-Authenticated-Sender: hampton.hostforweb.net: yamaoka@jpl.org X-Source: X-Source-Args: X-Source-Dir: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:129171 Archived-At: 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=3D"application/emacs-lisp" disposition=3Dinline> > (defun mm-shr (handle) > ... > ;; Remove "soft hyphens". > (goto-char (point-min)) > (while (search-forward "=C2=AD" nil t) > (replace-match "" t t)) > <#/part> ;; Note that "=C2=AD" is a soft hyphen. What Gnus wants to do is: (quoted-printable-encode-string (encode-coding-string "=C2=AD" 'iso-8859-1)) =3D> "=3DAD" However what is actually done is: (with-temp-buffer ;; `mml-generate-mime-1' does: (set-buffer-multibyte t) (insert "=C2=AD") ;; `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)) =3D> "=3D3FFFAD" Hmm. (with-temp-buffer (set-buffer-multibyte t) (insert "=C2=AD") (encode-coding-region (point-min) (point-max) 'iso-8859-1) (append (buffer-string) nil)) =3D> (4194221) This would probably be the multibyte version of: (append (encode-coding-string "=C2=AD" 'iso-8859-1) nil) =3D> (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 "=C2=AD") (encode-coding-region (point-min) (point-max) 'iso-8859-1) (set-buffer-multibyte nil) (quoted-printable-encode-region (point-min) (point-max)) (buffer-string)) =3D> "=3DAD" 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 "=C2=AD") (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)) =3D> "=3DAD" Regards,