From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.lisp.guile.user Subject: Re: bytevector-string-ref Date: Sun, 18 Dec 2022 17:38:11 +0100 Message-ID: References: <6b286bd0-1f66-c4d0-dc27-0b5e0fb154b6@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="u3XuXVUWzEpiKL9S" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24041"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Dec 18 17:38:49 2022 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p6wgb-00065H-6T for guile-user@m.gmane-mx.org; Sun, 18 Dec 2022 17:38:49 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6wgB-0004tg-BP; Sun, 18 Dec 2022 11:38:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6wg8-0004tB-8r for guile-user@gnu.org; Sun, 18 Dec 2022 11:38:20 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6wg6-0003xc-0L for guile-user@gnu.org; Sun, 18 Dec 2022 11:38:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jaH8fTFUq4svJCEgy9IwbLJtJ6FxPGlHx74A8//1OWY=; b=X8yVXegciYYE4+evw/uadiB9cS mCBx8eAXs7fsmI50PMpYvXhwA7gQJV07yXkJqRT7KGbcNrFKC7fBBKK6IlW0YVQeo2EmnKg4ZaJ6Y NqbeFw5OkR+bEUdrABLFYWjMxE+PUH9G1AxDOkUwSN84YWPO21MDVM0yLKYdN49s3dmEWRv2VG4t9 a+CNbugvGhrifPscXkyIooNSc/v4OPLq9c/YCD9sMvTVljeBpyne9HRMDB/z6HA+PUwOu9xb1+qHN UhWH5Fo5Xj+vTDNYTlMq7SarM/HO3go7qKQR1N4s3PaO09G9NfiK3pAVAXMQOnCzRuA6AF35DoC/T CMhYxOAw==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1p6wfz-0007WH-9z for guile-user@gnu.org; Sun, 18 Dec 2022 17:38:11 +0100 Content-Disposition: inline In-Reply-To: <6b286bd0-1f66-c4d0-dc27-0b5e0fb154b6@gmail.com> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:18783 Archived-At: --u3XuXVUWzEpiKL9S Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 th= e API. > > Or is there any other way to extract a string from a byte vector, witho= ut > > copying the data twice? > >=20 >=20 > I don't think Guile currently has any way of giving you a string object t= hat's > backed by the contents of a bytevector, instead of a privately held copy = of those > bytevector contents. >=20 > AFAIK, there is only the utfX->string class of procedures, which give you= a "newly > allocated" string from the bytevector's contents: >=20 > https://www.gnu.org/software/guile/manual/html_node/Bytevectors-as-String= s.html >=20 > That should only lead to the contents being copied once, however. I'm no= t 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 --=20 t --u3XuXVUWzEpiKL9S Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCY59B5gAKCRAFyCz1etHa Rq/LAJ91jo5ZGMs7m275L1DJq4Aniii73gCfWH90FWv4EFhLfQdhXJwuaPqAMdQ= =owOe -----END PGP SIGNATURE----- --u3XuXVUWzEpiKL9S--