From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Linus_Bj=C3=B6rnstam?= Newsgroups: gmane.lisp.guile.user Subject: Re: What is the point of bytevectors? Date: Sat, 12 Sep 2020 12:35:42 +0200 Message-ID: References: <663bcc3f7ca042bfd727cbcecb0dccfcde43aec8.camel@divoplade.fr> Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38772"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.3.0-259-g88fbbfa-fm-20200903.003-g88fbbfa3 To: divoplade , "Guile User" Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sat Sep 12 12:36:21 2020 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 1kH2tJ-000A03-RE for guile-user@m.gmane-mx.org; Sat, 12 Sep 2020 12:36:21 +0200 Original-Received: from localhost ([::1]:44910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kH2tI-0005XR-St for guile-user@m.gmane-mx.org; Sat, 12 Sep 2020 06:36:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kH2t8-0005X6-46 for guile-user@gnu.org; Sat, 12 Sep 2020 06:36:10 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:41275) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kH2t3-00019W-Oc for guile-user@gnu.org; Sat, 12 Sep 2020 06:36:09 -0400 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id F2E915C0071; Sat, 12 Sep 2020 06:36:03 -0400 (EDT) Original-Received: from imap1 ([10.202.2.51]) by compute4.internal (MEProxy); Sat, 12 Sep 2020 06:36:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.se; h= mime-version:message-id:in-reply-to:references:date:from:to :subject:content-type:content-transfer-encoding; s=fm1; bh=uxIm7 VgOQ5jAVWjGt4y5STykMgjzYDGJr26HValhVck=; b=NBnLkJt+my3GOzKNZsSE2 uTiw9DpUKByd1h5n6T1XNjCg9bPsmXgXEHNZaP3MpRyay0aHS0tgLsBlqgteJX9F zijQSbGT870k5J7CiWqyyMXMNDQMyifH/SNeVmd0frIxf3Q3Wa1vF+Bj+aKTD/8m SZ77ddHaVQn4aNhY+VVctDnTspyctY4DZlF5X3ZCZaI5n3dmsqUEPmvf3qQdpZ3G NU1TK0S5jIaKmTzoAQoD65xiiMM4HP3gLa8lg3QNXyO9d9w/eiiLoAy1JgtqE+Q9 BC8HrXDAapMqA/ZsEcNygL2kjOlGj6b9Vyy0PE+U26b4SfBwUn+n+63V7I3DzJ+y w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=uxIm7VgOQ5jAVWjGt4y5STykMgjzYDGJr26HValhV ck=; b=La8AwU8k08oML91t1IxLs+wcl1ZAfTKYLvUjYIhv5q2BeCxn4p1ZiAjZj BZvkj7NyZVLIGLMBiVCJ2O6wJ0vpYZgRWQpUpILHiVIzlfwtlJlf8aFp4gso+gU6 /2AsCFxj6356sJflmm7FKZGITzDhYLkufUAIKo/jhZLosvI6tgNqMqy37Sv/dndT G+50EQavaSXuVKq3Qp5SB8pJMI9O1t38lwOfhyybV4nSUvRLCsKfTbsIrMyd514V LUV3zVKyYyRxe0Rhq5RJBtavVvqlzGo6XrcG38xJ6nu+dn/aGghPWd+yA2aLqAS8 XQftlzIndDechfOt9+7IY9CnoPHkA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudeiuddgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpefnihhn uhhspgeujhpnrhhnshhtrghmuceolhhinhhushdrihhnthgvrhhnvghtsehfrghsthhmrg hilhdrshgvqeenucggtffrrghtthgvrhhnpefgtdfgudduueegueffieduveeileejudeu tdfgieelkeekkefggedvueefleetveenucffohhmrghinhepuhhtfhekvghvvghrhiifhh gvrhgvrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomheplhhinhhushdrihhnthgvrhhnvghtsehfrghsthhmrghilhdrshgv X-ME-Proxy: Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8132EC200A5; Sat, 12 Sep 2020 06:36:03 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <663bcc3f7ca042bfd727cbcecb0dccfcde43aec8.camel@divoplade.fr> Received-SPF: pass client-ip=66.111.4.29; envelope-from=linus.internet@fastmail.se; helo=out5-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/12 06:36:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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.23 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" Xref: news.gmane.io gmane.lisp.guile.user:16906 Archived-At: The point is to work with binary data, of which the most common type of = C strings are one kind. If you are using libguile in your C code you can use guile strings in yo= ur C code and pass them around to avoid the encoding/decoding overhead. = Or, the other way around, expose the procedures that work with whatever = C string representation your are using to guile. If your latin1 strings contain unicode data they are not latin1. --=20 Linus Bj=C3=B6rnstam On Sat, 12 Sep 2020, at 09:49, divoplade wrote: > Hello guile users, >=20 > I am writing a library mixing some scheme code and C code, and I have > two options for interfacing C strings: > 1. Use bytevectors; > 2. Use strings with byte access semantics (so-called latin-1, which is= > really a misleading name since it will most certainly contain utf-8- > encoded unicode text). >=20 > From the C side, they have nearly identical APIs, and the conversion > functions do not transcode anything. >=20 > From the scheme side, however: > 1. The bytevector library needs to be imported; > 2. The function names have way more characters to type; > 3. The bytevector library is missing a lot of text functions (like > join, split, trim, pad, searching...). >=20 > If the user wants to always manipulate unicode (decoded) strings, usin= g > either bytevectors or latin-1 strings require transcoding to enter the= > library and to exit the library, so either option is valid. >=20 > But if the user wants to always manipulate utf-8-encoded strings [1], > using bytevectors is impossible or much more difficult (see points > above). >=20 > So, why should I ever use bytevectors? >=20 > divoplade >=20 > [1] https://utf8everywhere.org/ >=20 >=20 >