On this page:
3.5.1 Characters and Scalar Values
char?
char->integer
integer->char
char-utf-8-length
3.5.2 Character Comparisons
char=?
char<?
char<=?
char>?
char>=?
char-ci=?
char-ci<?
char-ci<=?
char-ci>?
char-ci>=?
3.5.3 Classifications
char-alphabetic?
char-lower-case?
char-upper-case?
char-title-case?
char-numeric?
char-symbolic?
char-punctuation?
char-graphic?
char-whitespace?
char-blank?
char-iso-control?
char-general-category
make-known-char-range-list
3.5.4 Character Conversions
char-upcase
char-downcase
char-titlecase
char-foldcase

3.5 Characters

+Characters in The Racket Guide 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? v)  boolean?
  v : any/c
Return #t if v is a character, #f otherwise.

(char->integer char)  exact-integer?
  char : char?
Returns a character’s code-point number.

Example:

> (char->integer #\A)

65

(integer->char k)  char?
  k : 
(and/c exact-integer?
       (or/c (integer-in 0 55295)
             (integer-in 57344 1114111)))
Return the character whose code-point number is k. For k less than 256, the result is the same object for the same k.

Example:

> (integer->char 65)

#\A

(char-utf-8-length char)  (integer-in 1 6)
  char : char?
Produces the same result as (bytes-length (string->bytes/utf-8 (string char))).

3.5.2 Character Comparisons

(char=? char1 char2 ...+)  boolean?
  char1 : char?
  char2 : char?
Returns #t if all of the arguments are eqv?.

Examples:

> (char=? #\a #\a)

#t

> (char=? #\a #\A #\a)

#f

(char<? char1 char2 ...+)  boolean?
  char1 : char?
  char2 : char?
Returns #t if the arguments are sorted increasing, where two characters are ordered by their scalar values, #f otherwise.

Examples:

> (char<? #\A #\a)

#t

> (char<? #\a #\A)

#f

> (char<? #\a #\b #\c)

#t

(char<=? char1 char2 ...+)  boolean?
  char1 : char?
  char2 : char?
Like char<?, but checks whether the arguments are nondecreasing.

Examples:

> (char<=? #\A #\a)

#t

> (char<=? #\a #\A)

#f

> (char<=? #\a #\b #\b)

#t

(char>? char1 char2 ...+)  boolean?
  char1 : char?
  char2 : char?
Like char<?, but checks whether the arguments are decreasing.

Examples:

> (char>? #\A #\a)

#f

> (char>? #\a #\A)

#t

> (char>? #\c #\b #\a)

#t

(char>=? char1 char2 ...+)  boolean?
  char1 : char?
  char2 : char?
Like char<?, but checks whether the arguments are nonincreasing.

Examples:

> (char>=? #\A #\a)

#f

> (char>=? #\a #\A)

#t

> (char>=? #\c #\b #\b)

#t

(char-ci=? char1 char2 ...+)  boolean?
  char1 : char?
  char2 : char?
Returns #t if all of the arguments are eqv? after locale-insensitive case-folding via char-foldcase.

Examples:

> (char-ci=? #\A #\a)

#t

> (char-ci=? #\a #\a #\a)

#t

(char-ci<? char1 char2 ...+)  boolean?
  char1 : char?
  char2 : char?
Like char<?, but checks whether the arguments would be in increasing order if each was first case-folded using char-foldcase (which is locale-insensitive).

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?
Like char-ci<?, but checks whether the arguments would be nondecreasing after case-folding.

Examples:

> (char-ci<=? #\A #\a)

#t

> (char-ci<=? #\a #\A)

#t

> (char-ci<=? #\a #\b #\b)

#t

(char-ci>? char1 char2 ...+)  boolean?
  char1 : char?
  char2 : char?
Like char-ci<?, but checks whether the arguments would be decreasing after case-folding.

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?
Like char-ci<?, but checks whether the arguments would be nonincreasing after case-folding.

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?
Returns #t if char has the Unicode “Alphabetic” property.

(char-lower-case? char)  boolean?
  char : char?
Returns #t if char has the Unicode “Lowercase” property.

(char-upper-case? char)  boolean?
  char : char?
Returns #t if char has the Unicode “Uppercase” property.

(char-title-case? char)  boolean?
  char : char?
Returns #t if char’s Unicode general category is Lt, #f otherwise.

(char-numeric? char)  boolean?
  char : char?
Returns #t if char has the Unicode “Numeric” property.

(char-symbolic? char)  boolean?
  char : char?
Returns #t if char’s Unicode general category is Sm, Sc, Sk, or So, #f otherwise.

(char-punctuation? char)  boolean?
  char : char?
Returns #t if char’s Unicode general category is Pc, Pd, Ps, Pe, Pi, Pf, or Po, #f otherwise.

(char-graphic? char)  boolean?
  char : char?
Returns #t if char’s Unicode general category is Ll, Lm, Lo, Lt, Lu, Nd, Nl, No, Mn, Mc, or Me, or if one of the following produces #t when applied to char: char-alphabetic?, char-numeric?, char-symbolic?, or char-punctuation?.

(char-whitespace? char)  boolean?
  char : char?
Returns #t if char has the Unicode “White_Space” property.

(char-blank? char)  boolean?
  char : char?
Returns #t if char’s Unicode general category is Zs or if char is #\tab. (These correspond to horizontal whitespace.)

(char-iso-control? char)  boolean?
  char : char?
Return #t if char is between #\nul and #\u001F inclusive or #\rubout and #\u009F inclusive.

(char-general-category char)  symbol?
  char : char?
Returns a symbol representing the character’s Unicode general category, which is 'lu, 'll, 'lt, 'lm, 'lo, 'mn, 'mc, 'me, 'nd, 'nl, 'no, 'ps, 'pe, 'pi, 'pf, 'pd, 'pc, 'po, 'sc, 'sm, 'sk, 'so, 'zs, 'zp, 'zl, 'cc, 'cf, 'cs, 'co, or 'cn.

(make-known-char-range-list)
  
(listof (list/c exact-nonnegative-integer?
                exact-nonnegative-integer?
                boolean?))
Produces a list of three-element lists, where each three-element list represents a set of consecutive code points for which the Unicode standard specifies character properties. Each three-element list contains two integers and a boolean; the first integer is a starting code-point value (inclusive), the second integer is an ending code-point value (inclusive), and the boolean is #t when all characters in the code-point range have identical results for all of the character predicates above. The three-element lists are ordered in the overall result list such that later lists represent larger code-point values, and all three-element lists are separated from every other by at least one code-point value that is not specified by Unicode.

3.5.4 Character Conversions

(char-upcase char)  char?
  char : char?
Produces a character consistent with the 1-to-1 code point mapping defined by Unicode. If char has no upcase mapping, char-upcase produces 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?
Like char-upcase, but for the Unicode downcase mapping.

Examples:

> (char-downcase #\A)

#\a

> (char-downcase #\Λ)

#\λ

> (char-downcase #\space)

#\space

(char-titlecase char)  char?
  char : char?
Like char-upcase, but for the Unicode titlecase mapping.

Examples:

> (char-upcase #\a)

#\A

> (char-upcase #\λ)

#\Λ

> (char-upcase #\space)

#\space

(char-foldcase char)  char?
  char : char?
Like char-upcase, but for the Unicode case-folding mapping.

Examples:

> (char-foldcase #\A)

#\a

> (char-foldcase #\Σ)

#\σ

> (char-foldcase #\ς)

#\σ

> (char-foldcase #\space)

#\space