Skip to main content

UNICHARS

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

Synopsis

UNICHARS(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 UNICHARS function takes a dynamic array of character codes and returns a dynamic array containing the corresponding character for each element.

This is the inverse of the UNISEQS function, which 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, UNICHARS(10) returns a linefeed character.

Note:

UNICHARS and CHARS 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 UNICHARS function returns a dynamic array of characters. The corresponding ObjectScript $CHAR function returns a string of characters by specifying a comma-separated list of ASCII codes.

Examples

The following example uses the UNICHARS function to return a dynamic array of the characters associated with each specified ASCII character code:

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

The following example uses the UNICHARS 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 UNICHARS(b)

See Also

FeedbackOpens in a new tab