Skip to main content

UNICHAR

Returns the character corresponding to the specified character code.

Synopsis

UNICHAR(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 UNICHAR function takes a character code and returns the corresponding character. The UNISEQ function takes a character and returns the corresponding character code.

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

Note:

UNICHAR, CHAR, and BYTE 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 UNICHAR 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 UNICHARS function takes a dynamic array of ASCII codes and returns the corresponding single characters as a dynamic array.

Examples

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

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

The following example uses the UNICHAR 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 UNICHAR(letter)
  letter=letter+1
NEXT

See Also

FeedbackOpens in a new tab