From: Maxime Devos <maximedevos@telenet.be>
To: Vijay Marupudi <vijay@vijaymarupudi.com>, guile-devel@gnu.org
Subject: Re: [PATCH] Enable utf8->string to take a range
Date: Fri, 21 Jan 2022 23:08:25 +0100 [thread overview]
Message-ID: <b6244a9e9d16117c3ae47564f07bf6e38330c0b8.camel@telenet.be> (raw)
In-Reply-To: <87bl046dss.fsf@vijaymarupudi.com>
[-- Attachment #1.1: Type: text/plain, Size: 1169 bytes --]
Vijay Marupudi schreef op vr 21-01-2022 om 15:20 [-0500]:
+ (pass-if-exception "utf8->string range: end < start"
+ exception:out-of-range
+ (let* ((utf8 (string->utf8 "gnu guile")))
+ (utf8->string utf8 1 0)))
+ [other tests]
It would be nice to check multibyte characters as well,
to verify that byte indices and not character indices are used.
E.g., (utf8->string #vu8(195 169) 0 2) should return "é".
Another nice test: (utf8->string #vu8(195 169) 0 1) should raise
a 'decoding-error', even though #vu8(195 169) is valid UTF-8.
And (utf8->string #vu8(0 32 196) 0 2) should return "\x00 " even
though #vu8(0 32 195) is invalid UTF-8 -- and as a bonus, it checks
that the nul character is supported -- which can be easily forgotten
because Guile is implemented in C which usually terminates strings
by zero instead of using a length field.
Overall, the patch you sent seems a reasonable approach to me, though
I didn't verify the details. I find myself at times copying a part
of a bytevector to a new bytevector because some procedure doesn't
allow specifying byte ranges ...
Greetings,
Maxime
[-- Attachment #1.2: Type: text/html, Size: 1597 bytes --]
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
next prev parent reply other threads:[~2022-01-21 22:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 3:23 [PATCH] Enable utf8->string to take a range Vijay Marupudi
2022-01-21 16:53 ` Maxime Devos
2022-01-21 16:54 ` Maxime Devos
2022-01-21 16:55 ` Maxime Devos
2022-01-21 17:04 ` Maxime Devos
2022-01-21 20:20 ` Vijay Marupudi
2022-01-21 22:08 ` Maxime Devos [this message]
2022-01-22 1:21 ` Vijay Marupudi
2022-03-09 13:20 ` Maxime Devos
2022-03-09 13:20 ` Maxime Devos
2022-03-09 13:24 ` Maxime Devos
2022-03-09 13:27 ` Maxime Devos
2022-03-09 13:35 ` Maxime Devos
2022-03-09 14:50 ` Vijay Marupudi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b6244a9e9d16117c3ae47564f07bf6e38330c0b8.camel@telenet.be \
--to=maximedevos@telenet.be \
--cc=guile-devel@gnu.org \
--cc=vijay@vijaymarupudi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).