3.5 Characters
Characters in Guide: Racket introduces characters.
Characters range over Unicode scalar values, which includes characters whose values range from #x0 to #x10FFFF, but not including #xD800 to #xDFFF. The scalar values are a subset of the Unicode code points.
Two characters are eqv? if they correspond to the same scalar value. For each scalar value less than 256, character values that are eqv? are also eq?.
3.5.1 Characters and Scalar Values
(char->integer char) → exact-integer? |
char : char? |
Example: |
> (char->integer #\A) |
65 |
(integer->char k) → char? | |||||||||
|
Example: |
> (integer->char 65) |
#\A |
(char-utf-8-length char) → (integer-in 1 6) |
char : char? |
3.5.2 Character Comparisons
Examples: |
> (char=? #\a #\a) |
#t |
> (char=? #\a #\A #\a) |
#f |
Examples: |
> (char<? #\A #\a) |
#t |
> (char<? #\a #\A) |
#f |
> (char<? #\a #\b #\c) |
#t |
Examples: |
> (char<=? #\A #\a) |
#t |
> (char<=? #\a #\A) |
#f |
> (char<=? #\a #\b #\b) |
#t |
Examples: |
> (char>? #\A #\a) |
#f |
> (char>? #\a #\A) |
#t |
> (char>? #\c #\b #\a) |
#t |
Examples: |
> (char>=? #\A #\a) |
#f |
> (char>=? #\a #\A) |
#t |
> (char>=? #\c #\b #\b) |
#t |
Examples: |
> (char-ci=? #\A #\a) |
#t |
> (char-ci=? #\a #\a #\a) |
#t |
Examples: |
> (char-ci<? #\A #\a) |
#f |
> (char-ci<? #\a #\b) |
#t |
> (char-ci<? #\a #\b #\c) |
#t |
(char-ci<=? char1 char2 ...+) → boolean? |
char1 : char? |
char2 : char? |
Examples: |
> (char-ci<=? #\A #\a) |
#t |
> (char-ci<=? #\a #\A) |
#t |
> (char-ci<=? #\a #\b #\b) |
#t |
Examples: |
> (char-ci>? #\A #\a) |
#f |
> (char-ci>? #\b #\A) |
#t |
> (char-ci>? #\c #\b #\a) |
#t |
(char-ci>=? char1 char2 ...+) → boolean? |
char1 : char? |
char2 : char? |
Examples: |
> (char-ci>=? #\A #\a) |
#t |
> (char-ci>=? #\a #\A) |
#t |
> (char-ci>=? #\c #\b #\b) |
#t |
3.5.3 Classifications
(char-alphabetic? char) → boolean? |
char : char? |
(char-lower-case? char) → boolean? |
char : char? |
(char-upper-case? char) → boolean? |
char : char? |
(char-title-case? char) → boolean? |
char : char? |
(char-numeric? char) → boolean? |
char : char? |
(char-symbolic? char) → boolean? |
char : char? |
(char-punctuation? char) → boolean? |
char : char? |
(char-graphic? char) → boolean? |
char : char? |
(char-whitespace? char) → boolean? |
char : char? |
(char-blank? char) → boolean? |
char : char? |
(char-iso-control? char) → boolean? |
char : char? |
(char-general-category char) → symbol? |
char : char? |
(make-known-char-range-list) | |||||||
|
3.5.4 Character Conversions
(char-upcase char) → char? |
char : char? |
String procedures, such as string-upcase, handle the case where Unicode defines a locale-independent mapping from the code point to a code-point sequence (in addition to the 1-1 mapping on scalar values).
Examples: |
> (char-upcase #\a) |
#\A |
> (char-upcase #\λ) |
#\Λ |
> (char-upcase #\space) |
#\space |
(char-downcase char) → char? |
char : char? |
Examples: |
> (char-downcase #\A) |
#\a |
> (char-downcase #\Λ) |
#\λ |
> (char-downcase #\space) |
#\space |
(char-titlecase char) → char? |
char : char? |
Examples: |
> (char-upcase #\a) |
#\A |
> (char-upcase #\λ) |
#\Λ |
> (char-upcase #\space) |
#\space |
(char-foldcase char) → char? |
char : char? |
Examples: |
> (char-foldcase #\A) |
#\a |
> (char-foldcase #\Σ) |
#\σ |
> (char-foldcase #\ς) |
#\σ |
> (char-foldcase #\space) |
#\space |