Convert subject to list.

This commit is contained in:
Dominik Pantůček 2023-04-11 14:07:21 +02:00
parent 947e1c8771
commit 418468f46e
3 changed files with 12 additions and 4 deletions

View file

@ -32,6 +32,7 @@
string-first+rest
string-utf8?
string-tests!
string->list/utf8
)
(import scheme
@ -63,8 +64,12 @@
;; Returns true, if given string contains UTF-8 characters
(define (string-utf8? str)
(let ((asciilen (string-length str))
(utf8len (length (irregex-extract (irregex "." 'u) str))))
(utf8len (length (string->list/utf8 str))))
(not (= asciilen utf8len))))
;; Converts given UTF-8 string into a list of UTF-8 string characters.
(define (string->list/utf8 str)
(irregex-extract (irregex "." 'u) str))
;; Performs utils module self-tests.
(define (string-tests!)