XLISP int-char

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# int-char

Type: | - | function (subr)
Source: | - | xlstr.c

## Syntax

(int-char int)
  int - an integer numeric expression
  returns - the character with that code

## Description

The 'int-char' function returns a character which is the result of turning the 'int' expression into a character. If a 'int' cannot be made into a character, an error is signalled:

    error: character code out of range

The range that 'int' produces a valid character is 0 through 255.

## Examples

    (int-char 48)    ; returns #\0
    (int-char 65)    ; returns #\A
    (int-char 97)    ; returns #\a
    (int-char 91)    ; returns #\[
    (int-char 10)    ; returns #\Newline
    (int-char 999)   ; error - character code out of range

Common Lisp: Common Lisp specifies that 'int-char' should return a NIL when there is no valid character for the integer value being passed in while XLISP generates an error in these cases. In some cases it is possible to substitue the code-char function for 'int-char'.

Note: Unlike the char-code and char-int functions, code-char and 'int-char' are not identical in use. code-char accepts 0..127 for its range and then produces NIL results while 'int-char' accepts 0..255 for its range and then produces errors.

See the int-char function in the XLISP 2.0 manual.

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference