From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alain Schneble Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] url: Wrap cookie headers in url-http--encode-string. Date: Fri, 9 Sep 2016 17:16:49 +0200 Message-ID: <86k2elqf1a.fsf@realize.ch> References: <20160907153014.15752-1-toke@toke.dk> <87inu7k5z4.fsf@toke.dk> <83bmzzaawr.fsf@gnu.org> <877fank1oc.fsf@toke.dk> <87inu6iim8.fsf@toke.dk> <2563921f-d20d-753b-09eb-c8671bc5b6d6@yandex.ru> <87a8fiidso.fsf@toke.dk> <86sht9qfyh.fsf@realize.ch> <8360q5868c.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1473434254 32735 195.159.176.226 (9 Sep 2016 15:17:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Sep 2016 15:17:34 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt) Cc: toke@toke.dk, dgutov@yandex.ru, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 09 17:17:30 2016 Return-path: Envelope-to: ged-emacs-devel@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 1biNYR-0007Eg-Ep for ged-emacs-devel@m.gmane.org; Fri, 09 Sep 2016 17:17:23 +0200 Original-Received: from localhost ([::1]:58442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biNYP-0001US-Cg for ged-emacs-devel@m.gmane.org; Fri, 09 Sep 2016 11:17:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biNYC-0001Q6-RI for emacs-devel@gnu.org; Fri, 09 Sep 2016 11:17:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1biNYB-0003nD-Se for emacs-devel@gnu.org; Fri, 09 Sep 2016 11:17:08 -0400 Original-Received: from clientmail.realize.ch ([46.140.89.53]:3540) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1biNY9-0003lx-VN; Fri, 09 Sep 2016 11:17:06 -0400 Original-Received: from rintintin.hq.realize.ch.lan.rit ([192.168.0.105]) by clientmail.realize.ch ; Fri, 9 Sep 2016 17:17:00 +0200 Original-Received: from MYNGB (192.168.66.65) by rintintin.hq.realize.ch.lan.rit (192.168.0.105) with Microsoft SMTP Server (TLS) id 15.0.516.32; Fri, 9 Sep 2016 17:16:50 +0200 In-Reply-To: <8360q5868c.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 09 Sep 2016 18:04:19 +0300") X-ClientProxiedBy: rintintin.hq.realize.ch.lan.rit (192.168.0.105) To rintintin.hq.realize.ch.lan.rit (192.168.0.105) X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] X-Received-From: 46.140.89.53 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207315 Archived-At: Eli Zaretskii writes: >> (string-bytes cookie-val) >> =3D> 131 >> (string-bytes (encode-coding-string "=E6=F8=E5" 'utf-8)) >> =3D> 6 >> (string-bytes (concat (encode-coding-string "=E6=F8=E5" 'utf-8) cookie-v= al)) >> =3D> 143 ' why? >> (string-bytes (concat (string-as-unibyte "abc") ans-cookie-val)) >> =3D> 134 > > Because a multibyte string with ASCII-only text has the same number of > bytes as it has characters. While a multibyte string with non-ASCII > text has more bytes than characters, due to the way Emacs represents > characters internally (which is actually a superset of UTF-8). > >> Why does concat behave that strangely? What am I missing here? Is the >> behavior of concatenating a unibyte and a multibyte string simply >> undefined? > > No, it isn't undefined. When some of the arguments are multibyte > strings, concat returns a multibyte string. Nothing else would make > sense. Thanks!