Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section

Chr

Returns the character corresponding to the specified ANSI character code.

Synopsis

Chr(charcode)

Arguments

The charcode argument is a decimal integer that identifies a character. For 8-bit characters, the value in charcode must evaluate to a positive integer in the range 0 to 255. For 16-bit characters, specify integers in the range 256 through 65534.

Description

The Chr function takes an ANSI code and returns the corresponding character. The Asc function takes a character and returns the corresponding ANSI code.

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

The Caché Basic Chr function returns a single character. The corresponding ObjectScript $CHAR function can return multiple characters by specifying a comma-separated list of ASCII codes.

Examples

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

Println Chr(65)    ' Returns A.
Println Chr(97)    ' Returns a.
Println Chr(37)    ' Returns %.
Println Chr(62)    ' Returns >.
Println Chr(960)   ' Returns the symbol for pi.
Copy code to clipboard

See Also

  • Basic: Asc function

  • ObjectScript: $CHAR function