ascii-string? predicate Lassi Kortela 20 Sep 2019 09:51 UTC

John:
 > 5) Add predicates ascii-codepoint? and ascii-string?.  The latter
will be very valuable.

It may be a good idea to add `ascii-string?` but what would be its
semantics?

- Obviously a zero-length string should be considered an ASCII string.

- Otherwise, all codepoints need to be ASCII 0..127.

- What about control characters? Probably a string with ASCII control
characters should count as an ASCII string, even if control characters
often cause problems.

Note that you can already do:

(import (srfi 13) (srfi 175))
(string-every ascii-char? "") => #t
(string-every ascii-char? "hello world") => #t
(string-every ascii-char? "hello wörld") => #f

And it's more versatile than an `ascii-string?`:

(string-every ascii-char? "\0") => #t
(string-every ascii-display? "\0") => #f
(string-every ascii-lower-case? "hello") => #t
(string-every ascii-lower-case? "hello world") => #f
(string-every ascii-alphabetic? "HELLOworld") => #t

Do you have particular arguments or examples where `ascii-string?` would
be better than just using string-every with one of the existing predicates?