char->integer, integer->char - conversion between characters and integers
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
(char->integer char)
(integer->char sv)
Given a Unicode character, char->integer returns an exact integer
between 0 and #xD7FF or between #xE000 and
#x10FFFF which is equal to the Unicode scalar value of that character.
- R6RS
- Sv must be a Unicode scalar value, i.e., a non-negative exact
integer object in [0, #xD7FF] ∪ [#xE000, #x10FFFF]. For a Unicode
scalar value sv, integer->char returns its associated
character.
- R7RS
- Given an exact integer that is the value returned by a character when
char->integer is applied to it, integer->char returns
that character.
- Given a non-Unicode character, it returns an exact integer greater than
#x10FFFF. This is true independent of whether the implementation
uses the Unicode representation internally.
Returns a single integer and character object, respectively.
(integer->char 32)
=> #\space
(char->integer (integer->char 5000))
=> 5000
(integer->char #\xD800)
=> &assertion exception ;R6RS
R6RS defines these procedures in terms of Unicode scalar values. R7RS allows an
implementation to support additional characters, and to omit support for some
Unicode characters. R5RS defines these procedures so that char<=? on
characters matches <= on the corresponding scalar values.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
- The wrong number of arguments was passed or an argument was outside its
domain. In particular, &assertion must be raised when the
argument is not a Unicode scalar value (see above).
- R7RS
- The assertions described above are errors. Implementations may signal an
error, extend the procedure's domain of definition to include such
arguments, or fail catastrophically.
R4RS, IEEE Scheme, R5RS, R6RS, R7RS