Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see How to Migrate to InterSystems IRIS, available on the WRC Distributions page (login required).

CHAR

Returns the character corresponding to the specified character code.

Synopsis

CHAR(charcode)

Arguments

charcode An expression that resolves to a base-10 integer that identifies a character. For 8-bit characters, charcode must be a positive integer in the range 0 through 255. For 16-bit characters, charcode must be a positive integer in the range 256 through 65534.

Description

The CHAR function takes a character code and returns the corresponding character. The SEQ function takes a character and returns the corresponding ASCII code.

Numbers from 0 to 31 are the same as standard, nonprintable ASCII codes. For example, CHAR(10) returns a linefeed character.

Note:

CHAR, BYTE, and UNICHAR are functionally identical. On Unicode systems both can be used to return 16-bit Unicode characters. On 8-bit systems, these functions return a null string for character codes beyond 255.

The Caché MVBasic CHAR function returns a single character. The corresponding ObjectScript $CHAR function can return a string of multiple characters by specifying a comma-separated list of ASCII codes. The Caché MVBasic CHARS function takes a dynamic array of ASCII codes and returns the corresponding single characters as a dynamic array.

Examples

The following example uses the CHAR function to return the character associated with the specified character code:

PRINT CHAR(65);    ! Returns A.
PRINT CHAR(97);    ! Returns a.
PRINT CHAR(37);    ! Returns %.
PRINT CHAR(62);    ! Returns >.

The following example uses the CHAR function to return the lowercase letter characters of the Russian alphabet on a Unicode version of Caché. On an 8-bit version of Caché it returns a null string for each letter:

letter=1072
FOR x=1 TO 32
  PRINT CHAR(letter)
  letter=letter+1
NEXT

See Also

Feedback