string-upcase(3scm) Scheme Programmer's Manual string-upcase(3scm)

string-upcase, string-downcase, string-titlecase, string-foldcase - string case conversion

(import (rnrs))                     ;R6RS
(import (rnrs unicode))             ;R6RS
(import (scheme char))              ;R7RS

(string-upcase string)
(string-downcase string)
(string-titlecase string)           ;R6RS
(string-foldcase string)

Returns a case-converted version of string.
string-upcase
Converts a string to upper case.
string-downcase
Converts a string to lower case.
string-foldcase
Converts the string to its case-folded counterpart, using the full case-folding mapping, but without the special mappings for Turkic languages.
string-titlecase
Converts the first cased character of each word, and downcases all other cased characters.

These procedures are defined in terms of Unicode's locale-independent case mappings from Unicode scalar-value sequences to scalar-value sequences. In particular, the length of the result string can be different from the length of the input string.

Since these procedures are locale-independent, they may not be appropriate for some locales.

R7RS
The Unicode Standard prescribes special treatment of the Greek letter Σ, whose normal lower-case form is σ but which becomes ς at the end of a word. See Unicode Standard Annex #44 for details. However, implementations of string-downcase are not required to provide this behavior, and may choose to change Σ to σ in all cases.

The case mappings needed for implementing these procedures can be extracted from UnicodeData.txt, SpecialCasing.txt, WordBreakProperty.txt, and CaseFolding.txt from the Unicode Consortium.

Word breaking, as needed for the correct casing of Σ and for string-titlecase, is specified in Unicode Standard Annex #29.

These procedures return a single value; a string.

When the specified result is equal in the sense of string=?(3scm) to the argument, these procedures may return the argument instead of a newly allocated string.

(string-upcase "Hi")               =>  "HI"
(string-downcase "Hi")             =>  "hi"
(string-foldcase "Hi")             =>  "hi"
(string-upcase "Straße")           =>  "STRASSE"
(string-downcase "Straße")         =>  "straße"
(string-foldcase "Straße")         =>  "strasse"
(string-downcase "STRASSE")        =>  "strasse"
(string-downcase "Σ")              =>  "σ"
;; Chi Alpha Omicron Sigma.
;; See the note on R7RS in the description.
(string-upcase "ΧΑΟΣ")             =>  "ΧΑΟΣ"
(string-downcase "ΧΑΟΣ")           =>  "χαος"
(string-downcase "ΧΑΟΣΣ")          =>  "χαοσς"
(string-downcase "ΧΑΟΣ Σ")         =>  "χαος σ"
(string-foldcase "ΧΑΟΣΣ")          =>  "χαοσσ"
(string-upcase "χαος")             =>  "ΧΑΟΣ"
(string-upcase "χαοσ")             =>  "ΧΑΟΣ"
(string-titlecase "kNock KNoCK")   =>  "Knock Knock"
(string-titlecase "who's there?")  =>  "Who's There?"
(string-titlecase "r6rs")          =>  "R6rs"
(string-titlecase "R6RS")          =>  "R6rs"

In R6RS implementations, case conversion differs according to which Unicode version is supported. R7RS does not have string-titlecase.

This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
R7RS
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

char-upper-case?(3scm)

Unicode Standard Annex #44: Unicode Character Database.

Unicode Standard Annex #29: Unicode Text Segmentation.

R6RS, R7RS

The first Scheme report with these procedures is R6RS. They were later also added in R7RS, except for string-titlecase.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

2022-05-13