Skip to main content

CHARS

Returns the character corresponding to the specified character code for each element of a dynamic array.

Synopsis

CHARS(dynarray)

Arguments

dynarray An expression that resolves to a dynamic array of base-10 integers that identify characters. For 8-bit characters, each element value must be a positive integer in the range 0 through 255. For 16-bit characters, each element value must be a positive integer in the range 256 through 65534.

Description

The CHARS function takes a dynamic array of character codes and returns the corresponding characters. It returns these values as a dynamic array. The SEQS function takes a dynamic array of characters and returns the corresponding character codes.

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

Note:

CHARS and UNICHARS 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 greater than 255.

The Caché MVBasic CHARS function returns a dynamic array of characters. The corresponding ObjectScript $CHAR function returns a string of characters by specifying a comma-separated list of character codes.

Examples

The following example uses the CHARS function to return the characters associated with each specified character code:

a=65:@VM:66:@VM:67:@VM:68
PRINT CHARS(a);  ! returns AýBýCýD

The following example uses the CHARS function to return the first four letters of the Greek alphabet. On a Unicode version of Caché it returns the Greek letters in a dynamic array; on an 8-bit version of Caché it returns a dynamic array with a null string for each letter:

b=945:@VM:946:@VM:947:@VM:948
PRINT CHARS(b)

See Also

FeedbackOpens in a new tab