Next: , Previous: Comparison of Characters, Up: Characters

5.3 Miscellaneous Character Operations

— procedure: char? object

Returns #t if object is a character; otherwise returns #f.

— procedure: char-upcase char
— procedure: char-downcase char

Returns the uppercase or lowercase equivalent of char if char is a letter; otherwise returns char. These procedures return a character char2 such that (char-ci=? char char2).

Note: Although character objects can represent all of Unicode, the model of alphabetic case used covers only ASCII letters, which means that case-insensitive comparisons and case conversions are incorrect for non-ASCII letters. This will eventually be fixed.

— procedure: char->digit char [radix]

If char is a character representing a digit in the given radix, returns the corresponding integer value. If you specify radix (which must be an exact integer between 2 and 36 inclusive), the conversion is done in that base, otherwise it is done in base 10. If char doesn't represent a digit in base radix, char->digit returns #f.

Note that this procedure is insensitive to the alphabetic case of char.

          (char->digit #\8)                       =>  8
          (char->digit #\e 16)                    =>  14
          (char->digit #\e)                       =>  #f
— procedure: digit->char digit [radix]

Returns a character that represents digit in the radix given by radix. Radix must be an exact integer between 2 and 36 (inclusive), and defaults to 10. Digit, which must be an exact non-negative integer, should be less than radix; if digit is greater than or equal to radix, digit->char returns #f.

          (digit->char 8)                         =>  #\8
          (digit->char 14 16)                     =>  #\E