guile-user
[Top][All Lists]
Advanced

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

Re: bytevector-string-ref


From: tomas
Subject: Re: bytevector-string-ref
Date: Sun, 18 Dec 2022 17:38:11 +0100

On Sun, Dec 18, 2022 at 05:25:16PM +0100, Taylan Kammer wrote:
> On 18.12.2022 13:12, Sascha Ziemann wrote:
> > I am wondering if something like bytevector-string-ref is missing in the 
> > API.
> > Or is there any other way to extract a string from a byte vector, without
> > copying the data twice?
> > 
> 
> I don't think Guile currently has any way of giving you a string object that's
> backed by the contents of a bytevector, instead of a privately held copy of 
> those
> bytevector contents.
> 
> AFAIK, there is only the utfX->string class of procedures, which give you a 
> "newly
> allocated" string from the bytevector's contents:
> 
> https://www.gnu.org/software/guile/manual/html_node/Bytevectors-as-Strings.html
> 
> That should only lead to the contents being copied once, however.  I'm not 
> sure
> why you asked "without copying the data twice."

I think you have to copy anyway -- unless your string's encoding is
strictly the same as Guile's internal encoding. Currently (I don't
know whether this is part of the official interface) it is dual:
either one byte/char (for texts encodable in iso-8859-1) or four
byte/char for all the others. representing Unicode code points (plus
some extra bits) I can't imagine it to be fun interfacing to that :-)

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


reply via email to

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