[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Replacement for string-as-unibyte-function
From: |
Stefan Monnier |
Subject: |
Re: Replacement for string-as-unibyte-function |
Date: |
Mon, 01 Feb 2021 10:01:22 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
>> 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).
Then use something like
(make-network-process ... :coding 'binary ...)
or
(make-network-process ... :coding '(binary . utf-8) ...)
> The filter function inserts the string into a buffer.
Emacs receives the data from the process as a sequence of *bytes* (after
all, that's the only thing available in POSIX communication). So in
order to pass a sequence of *chars* (aka "a multibyte string") to the
process filter, Emacs's internal C code has to do the equivalent of
(*de*code-coding-string "thedatareceived" '<somecodingsystem>)
where <somecodingsystem> is the coding system that
`make-network-process` decided to use for that process.
And then you come along and want to call `encode-coding-string` on the
result: better use `:coding` as I suggested above in order to cut the
middle man.
Stefan
- 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/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 <=