Next: Strings, Previous: Symbols, Up: Other data types [Contents][Index]
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.
Returns #t if obj is a character, otherwise returns #f.
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.
These procedures are similar to ‘char=?’ et cetera, but they treat upper case and lower case letters as the same. For example, ‘(char-ci=? #\A #\a)’ returns #t. Some implementations may generalize these procedures to take more than two arguments, as with the corresponding numerical predicates.
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.
Given a character, ‘char->integer’ returns an exact integer
representation of the character. Given an exact integer that is the image of
a character under ‘char->integer’, ‘integer->char’
returns that character. These procedures implement order-preserving isomorphisms
between the set of characters under the char<=?
ordering and some
subset of the integers under the ‘<=’ ordering. That is, if
(char<=? a b) ⇒ #t and (<= x y) ⇒ #t
and x and y are in the domain of ‘integer->char’, then
(<= (char->integer a) (char->integer b)) ==> #t (char<=? (integer->char x) (integer->char y)) ==> #t
These procedures return a character char2 such that ‘(char-ci=? char char2)’. In addition, if char is alphabetic, then the result of ‘char-upcase’ is upper case and the result of ‘char-downcase’ is lower case.
Next: Strings, Previous: Symbols, Up: Other data types [Contents][Index]