char-upcase(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

πŸ’– NAME πŸ’–

okay bestie, welcome to the char-upcase(3scm) page from the Scheme Programmer's Manual β€” this one is all about char-upcase, char-downcase, char-foldcase, and char-titlecase, aka case conversion πŸ’…βœ¨

πŸ“š LIBRARY πŸ“š

lowkey here are the imports you need:

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

✨ SYNOPSIS ✨

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

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so these procedures take a character argument and return a character result β€” no cap, that's the whole vibe 🫢

  • char-downcase β€” if the argument is an upper-case or title-case character, and if there's a single character that is its lower-case form, then char-downcase returns that character.
  • char-upcase β€” if the argument is a lower-case or title-case character, and if there's a single character that is its upper-case form, then char-upcase returns that character.
  • char-foldcase β€” if the character has a case-folded character, then char-foldcase returns that character. Otherwise the character returned is the same as the argument. For Turkic characters IΜ‡ (#\x130) and Δ± (#\x131), char-foldcase behaves as the identity function; otherwise char-foldcase is the same as char-downcase composed with char-upcase.
  • char-titlecase β€” if the argument is a lower-case or upper-case character, and there's a single character that is its title-case form, then char-titlecase returns that character. If the argument is not a title-case character and there's no single character that is its title-case form, then char-titlecase returns the upper-case form of the argument.

R7RS notes that language-sensitive folding and casing pairs are not used. πŸ“

πŸŽ€ RETURN VALUES πŸŽ€

Returns a single character object. periodt πŸ’–

πŸ”₯ EXAMPLES πŸ”₯

here's the vibe check, bestie:

(char-upcase #\i)     =>  #\I
(char-downcase #\i)   =>  #\i
(char-titlecase #\i)  =>  #\I
(char-foldcase #\i)   =>  #\i
;; The following might not be supported in R7RS implementations.
(char-upcase #\ß)     =>  #\ß
(char-downcase #\ß)   =>  #\ß
(char-titlecase #\ß)  =>  #\ß
(char-foldcase #\ß)   =>  #\ß
(char-upcase #\Ξ£)     =>  #\Ξ£
(char-downcase #\Ξ£)   =>  #\Οƒ
(char-titlecase #\Ξ£)  =>  #\Ξ£
(char-foldcase #\Ξ£)   =>  #\Οƒ
(char-upcase #\Ο‚)     =>  #\Ξ£
(char-downcase #\Ο‚)   =>  #\Ο‚
(char-titlecase #\Ο‚)  =>  #\Ξ£
(char-foldcase #\Ο‚)   =>  #\Οƒ

🌈 COMPATIBILITY 🌈

R5RS and earlier reports do not have char-foldcase and char-titlecase. R7RS does not have char-titlecase. R7RS implementations may or may not support Unicode, but they are required to support ASCII.

In R6RS implementations and other implementations that support Unicode, the behavior of these procedures depends on the supported Unicode version.

πŸ’€ ERRORS πŸ’€

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.

πŸ‘€ SEE ALSO πŸ‘€

char-upper-case?(3scm), char-lower-case?(3scm) β€” go check those besties too 🫢

πŸ‘‘ STANDARDS πŸ‘‘

R4RS, IEEE Scheme, R5RS, R6RS, R7RS

🌸 HISTORY 🌸

R5RS and earlier reports make no provisions for Unicode. ASCII is mentioned but implementations may even run on EBCDIC. Implementations of R5RS may support Unicode, but historically many implementations used ISO-8859-n and other character sets which are now subsets of Unicode.

🧚 AUTHORS 🧚

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


xoxo, your fav Unix bestie πŸ’– β€” signing off from the char-upcase(3scm) page, dated 2021-02-21 πŸŽ€βœ¨

πŸ“¦ where this page comes from