diff --git a/doc/utils.md b/doc/utils.md index 9914d2e..17eced1 100644 --- a/doc/utils.md +++ b/doc/utils.md @@ -448,6 +448,13 @@ characters of the 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. + ### Tag (import util-tag) diff --git a/src/util-string.scm b/src/util-string.scm index a17a515..6857c71 100644 --- a/src/util-string.scm +++ b/src/util-string.scm @@ -37,6 +37,8 @@ string->qp + string-upcase + string-tests! ) @@ -102,6 +104,12 @@ ""))) res))))) + ;; Returns upper-case version of the string + (define (string-upcase str) + (list->string + (map char-upcase + (string->list str)))) + ;; Performs utils module self-tests. (define (string-tests!) (run-tests @@ -129,6 +137,9 @@ (test-equal? string->qp (string->qp "asdfásdf") "asdf=c3=a1sdf") + (test-equal? string-upcase + (string-upcase "asdFGH") + "ASDFGH") )) )