Node:Characters, Next:Strings, Previous:Symbols, Up:Other data types
Characters are objects that represent printed characters such as letters and digits. Characters are written using the notation #\<character> or #\<character name>. For example:
- #\a
- ; lower case letter
- #\A
- ; upper case letter
- #\(
- ; left parenthesis
- #\
- ; the space character
- #\space
- ; the preferred way to write a space
- #\newline
- ; the newline character
Case is significant in #\<character>, but not in #\<character name>.
If <character> in #\<character> is alphabetic, then the character following <character> must be a delimiter character such as a space or parenthesis. This rule resolves the ambiguous case where, for example, the sequence of characters "#\ space" could be taken to be either a representation of the space character or a representation of the character "#\ s" followed by a representation of the symbol "pace."
Characters written in the #\ notation are self-evaluating. That is, they do not have to be quoted in programs.
Some of the procedures that operate on characters ignore the difference between upper case and lower case. The procedures that ignore case have "-ci" (for "case insensitive") embedded in their names.
char? obj | procedure |
Returns #t if obj is a character, otherwise returns #f. |
char=? char1 char2 | procedure |
char<? char1 char2 | procedure |
char>? char1 char2 | procedure |
char<=? char1 char2 | procedure |
char>=? char1 char2 | procedure |
These procedures impose a total ordering on the set of characters. It is guaranteed that under this ordering:
Some implementations may generalize these procedures to take more than two arguments, as with the corresponding numerical predicates. |
char-ci=? char1 char2 | library procedure |
char-ci<? char1 char2 | library procedure |
char-ci>? char1 char2 | library procedure |
char-ci<=? char1 char2 | library procedure |
char-ci>=? char1 char2 | library procedure |
These procedures are similar to |
char-alphabetic? char | library procedure |
char-numeric? char | library procedure |
char-whitespace? char | library procedure |
char-upper-case? letter | library procedure |
char-lower-case? letter | library procedure |
These procedures return #t if their arguments are alphabetic, numeric, whitespace, upper case, or lower case characters, respectively, otherwise they return #f. The following remarks, which are specific to the ASCII character set, are intended only as a guide: The alphabetic characters are the 52 upper and lower case letters. The numeric characters are the ten decimal digits. The whitespace characters are space, tab, line feed, form feed, and carriage return. |
char->integer char | procedure |
integer->char n | procedure |
Given a character, (char<=? a b) => #t and (<= x y) => #t and x and y are in the domain of
(<= (char->integer a) (char->integer b)) ==> #t (char<=? (integer->char x) (integer->char y)) ==> #t |
char-upcase char | library procedure |
char-downcase char | library procedure |
These procedures return a character char2 such that |