From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Wed, 28 Dec 2016 18:09:52 +0000
> Cc: larsi@gnus.org, dgutov@yandex.ru, kentaro.nakazawa@ni= fty.com,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0emacs-devel@gnu.org
>
>
> [1:text/plain Show]
>
>
> [2:text/html Hide Save:noname (9kB)]
>
> Eli Zaretskii <eliz@gnu.org> schrieb am Mi., 30. Nov. 2016 um 19:= 45 Uhr:
>
>=C2=A0 > From: Philipp Stephani <p.stephani2@gmail.com>= ;
>=C2=A0 > Date: Wed, 30 Nov 2016 18:23:14 +0000
>=C2=A0 > Cc: dgutov@yandex.ru, kentaro.nakazawa@nifty.co= m, emacs-devel@gnu.org
>=C2=A0 >
>=C2=A0 > > Yes, this is not a json.el problem at all. It does the= correct thing,
>=C2=A0 > > and shouldn't be changed.
>=C2=A0 >
>=C2=A0 > ??? Why should any code care whether a pure-ASCII string is= marked as
>=C2=A0 > unibyte or as multibyte? Both are "correct".
>=C2=A0 >
>=C2=A0 > I guess the problem is that process-send-string cares. If i= t didn't, we wouldn't have the problem.
>
>=C2=A0 I don't think I follow. The error we are talking about is si= gnaled
>=C2=A0 from url-http-create-request, not from process-send-string.
>
> Yes, but url-http-create-request only cares about unibyte strings beca= use the request it creates is passed to
> process-send-string, which special-cases unibyte strings.
How do you see that process-send-string special-cases unibyte strings?
>=C2=A0 > For URL, we'd need functions like
>=C2=A0 > (byte-array-length s) =3D (length (string-to-unibyte s))
>
>=C2=A0 Why do you need this? string-to-unibyte is well-defined only for=
>=C2=A0 unibyte or ASCII strings (if we forget the raw bytes for a momen= t), so
>=C2=A0 length will do.
>
> We need it because we have to send the byte length in a header. We can= 't just use (length s) because it
> would silently give a wrong result.
We are miscommunicating.=C2=A0 string-to-unibyte can only meaningfully be called on a pure-ASCII string, and for pure-ASCII strings 'length'<= br class=3D"gmail_msg"> will count bytes.=C2=A0 So I see no need for 'byte-array-length' if= its
implementation is as you indicated.
>=C2=A0 > (process-send-bytes s) =3D (process-send-string (string-to-= unibyte s))
>
>=C2=A0 Why is this needed? process-send-string already encodes its argu= ment,
>=C2=A0 which produces a unibyte string.
>
> We can't give a multibyte string to process-send-string, because w= e have to pass the length in bytes in a
> header first. Therefore we have to encode any string before passing it= to process-send-string.
Once you encoded the string, why do you need anything except calling
process-send-string?