emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New jrpc.el JSONRPC library (Was: [ELPA] New package: eglot)


From: Eli Zaretskii
Subject: Re: New jrpc.el JSONRPC library (Was: [ELPA] New package: eglot)
Date: Sat, 19 May 2018 17:11:01 +0300

> From: Philipp Stephani <address@hidden>
> Date: Sat, 19 May 2018 13:34:45 +0200
> Cc: Eli Zaretskii <address@hidden>, address@hidden, address@hidden, 
>       address@hidden
> 
> - 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]