[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Replacement for string-as-unibyte-function
From: |
Joe Riel |
Subject: |
Re: Replacement for string-as-unibyte-function |
Date: |
Sun, 31 Jan 2021 21:55:55 -0800 |
On Sun, 31 Jan 2021 22:03:42 -0500
Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> > Am handling a message passed in from an external process
> > (its passed in chunks).
> >
> > The header of the message specifies its length, in bytes.
> > Some of the characters may be unicode. Am using
> > buffer-substring-no-properties to later extract the message.
> > To get its length write, each byte has to be a character in the buffer.
>
> So make sure the buffer in which the process writes is unibyte with
>
> (set-buffer-multibyte nil)
>
> and make sure Emacs doesn't try to decode the process's output:
>
> (set-process-coding-system <proc> 'binary)
>
> (which you can also set directly when you launch the process, but how
> you do it depends on the function you use to create the process).
I'm actually using make-network-process (to communicate via tls).
The filter function inserts the string into a buffer.
I tried using (set-buffer-multibyte nil) and (insert string),
but that doesn't work. What does work is omitting the call to
set-buffer-multibyte and using
(insert (encode-coding-string string 'utf-8-unix)).
Previously I used (insert (string-as-unibyte string)).
--
Joe Riel
- Re: Replacement for string-as-unibyte-function,
Joe Riel <=
- Re: Replacement for string-as-unibyte-function, Eli Zaretskii, 2021/02/01
- Re: Replacement for string-as-unibyte-function, Joe Riel, 2021/02/01
- Re: Replacement for string-as-unibyte-function, Eli Zaretskii, 2021/02/01
- Re: Replacement for string-as-unibyte-function, Joe Riel, 2021/02/01
- Re: Replacement for string-as-unibyte-function, Eli Zaretskii, 2021/02/01
- Re: Replacement for string-as-unibyte-function, Joe Riel, 2021/02/01
- Re: Replacement for string-as-unibyte-function, Eli Zaretskii, 2021/02/02
Re: Replacement for string-as-unibyte-function, Stefan Monnier, 2021/02/01