Duck util-string.

This commit is contained in:
Dominik Pantůček 2023-07-06 19:47:17 +02:00
parent 3833196533
commit 722ac4830c
5 changed files with 58 additions and 56 deletions

View file

@ -371,3 +371,37 @@ A unifying module for compound data structures tagging.
Creates a unique and collision free symbol to identify compound data
structures based on lists and pairs.
## util-string [module]
(import util-string)
String manipulation functions which are used throughout other modules.
### string-first+rest [procedure]
(string-first+rest str)
* ```str``` - a string to split
Returns a pair of strings where the ```car``` of the pair is the first
token in the ```str``` given and ```cdr``` is a string with the
remainder with leading whitespace removed.
### string->qp [procedure]
(string->qp str)
* ```str``` - arbitrary string
Returns a new string with all non-ASCII characters encoded as
quoted-printable sequences.
### string-upcase [procedure]
(string-upcase str)
* ```str``` - arbitrary string
Returns the ```str``` with all characters converted to upper case
using ```char-upcase```. Does not work with UTF-8.

View file

@ -243,52 +243,3 @@ Returns a new lset instance from ```ls1``` with all elements in
* ```ls2``` - lset instance
Returns true if the sets contain exactly the same values.
### String
(import util-string)
String manipulation functions which are used throughout other modules.
(string-repeat str rep)
* ```str``` - string to repeat
* ```rep``` - number of repeats
Returns a string created by repeating the string ```str``` exactly
```rep``` number of times.
(string-first+rest str)
* ```str``` - a string to split
Returns a pair of strings where the ```car``` of the pair is the first
token in the ```str``` given and ```cdr``` is a string with the
remainder with leading whitespace removed.
(string-utf8? str)
* ```str``` - arbitrary string
Returns ```#t``` if given string ```str``` contains UTF-8 characters.
(string->list/utf8 str)
* ```str``` - arbitrary string
Returns a list of strings representing individual (possibly UTF-8)
characters of the string.
(string->qp str)
* ```str``` - arbitrary string
Returns a new string with all non-ASCII characters encoded as
quoted-printable sequences.
(string-upcase str)
* ```str``` - arbitrary string
Returns the ```str``` with all characters converted to upper case
using ```char-upcase```. Does not work with UTF-8.