help-gnu-emacs
[Top][All Lists]
Advanced

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

Replacement for string-as-unibyte-function


From: Joe Riel
Subject: Replacement for string-as-unibyte-function
Date: Sun, 31 Jan 2021 15:01:33 -0800

Apologies for this partial duplicate; after posting realized I no longer
receive email from this group, so renewed.  Am copying and responding to 
response
from the website:

Eli Zaretskii asks:
> Please describe your use case: what are you trying to do that you
> needed string-as-unibyte?

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.

It appears as though

   (encode-coding-string string 'utf-8-unix)

is the equivalent of (string-as-unibyte string).



-- 
Joe Riel




reply via email to

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