From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: New jrpc.el JSONRPC library (Was: [ELPA] New package: eglot) Date: Sat, 19 May 2018 17:11:01 +0300 Message-ID: <83lgcfhh1m.fsf@gnu.org> References: <87lgcrqgvz.fsf@gmail.com> <831seipvdb.fsf@gnu.org> <871se9lyid.fsf_-_@gmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1526738979 598 195.159.176.226 (19 May 2018 14:09:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 19 May 2018 14:09:39 +0000 (UTC) Cc: emacs-devel@gnu.org, joaotavora@gmail.com, vibhavp@gmail.com, monnier@iro.umontreal.ca To: Philipp Stephani Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat May 19 16:09:34 2018 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 1fK2YA-0008V9-Hh for ged-emacs-devel@m.gmane.org; Sat, 19 May 2018 16:09:34 +0200 Original-Received: from localhost ([::1]:43297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fK2aH-0008Bg-M4 for ged-emacs-devel@m.gmane.org; Sat, 19 May 2018 10:11:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fK2Zf-0008Bb-M2 for emacs-devel@gnu.org; Sat, 19 May 2018 10:11:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fK2Zb-0002e8-Ko for emacs-devel@gnu.org; Sat, 19 May 2018 10:11:07 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fK2Zb-0002e2-Gx; Sat, 19 May 2018 10:11:03 -0400 Original-Received: from [176.228.60.248] (port=2686 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fK2Za-0003Pg-Tv; Sat, 19 May 2018 10:11:03 -0400 In-reply-to: (message from Philipp Stephani on Sat, 19 May 2018 13:34:45 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:225439 Archived-At: > From: Philipp Stephani > Date: Sat, 19 May 2018 13:34:45 +0200 > Cc: Eli Zaretskii , monnier@iro.umontreal.ca, vibhavp@gmail.com, > emacs-devel@gnu.org > > - I think `string-bytes' isn't guaranteed to return the number of UTF-8 > bytes. Yes, it is guaranteed. See its implementation. There could be a problem if the original string includes raw bytes -- then the value returned by string-bytes will not match the length of the bytestream after encoding by UTF-8. But since JSON requires UTF-8 without any raw bytes, I'm not sure it matters that we will send an incorrect byte count in that case, because it means there's a bug in the Lisp program which produced the string. > Rather you should encode the string explicitly to a unibyte string > using `encode-coding-string', and then use `no-conversion' for the process > coding systems. That's possible, but since process-send-string encodes the string, it should be enough to bind coding-system-for-write to utf-8, and let process-send-string encode it. Assuming we trust the caller to produce a string without raw bytes, that is.