Skip to main content
Previous sectionNext section

CHAR

A string function that returns the character that has the ASCII code value specified in a string expression.

Synopsis

CHAR(code-value)
{fn CHAR(code-value)}

Arguments

Argument Description
code-value An integer code that corresponds to a character.

Description

CHAR returns the character that corresponds to the specified integer code value. Because InterSystems IRIS is a Unicode system, you can specify the integer code for any Unicode character, 0 through 65535. CHAR returns NULL if code-value is a integer that exceeds the permissible range of values.

CHAR returns an empty string ('') if code-value is a nonnumeric string. CHAR returns NULL if passed a NULL value.

Note that CHAR can be used as an ODBC scalar function (with the curly brace syntax) or as an SQL general function.

Examples

The following examples both return the character Z:

SELECT CHAR(90) AS CharCode
Copy code to clipboard
SELECT {fn CHAR(90)} AS CharCode
Copy code to clipboard

The following example returns the Greek letter lambda:

  &sql(SELECT {fn CHAR(955)}
       INTO :greeklet)
  WRITE !,"Greek letter: ",greeklet
Copy code to clipboard

See Also