Skip to main content

$WCHAR (ObjectScript)

Returns the character corresponding to a numeric code, recognizing surrogate pairs.




Argument Description
expression The integer value to be converted.


$WCHAR returns the character(s) corresponding to a code value(s) specified in expression. Decimal values of 65535 (hex FFFF) and smaller are processed identically by $CHAR and $WCHAR. Values from 65536 (hex 10000) through 1114111 (hex 10FFFF) are used to represent Unicode surrogate pairs; these characters can be returned using $WCHAR.

If expression contains a comma-separated list of code values, $WCHAR returns the corresponding characters as a string. $WCHAR recognizes a surrogate pair as a single character. You can use the $WISWIDE function to determine if a string contains a surrogate pair.

A surrogate pair is a pair of 16-bit InterSystems IRIS character elements that together encode a single Unicode character. Surrogate pairs are used to represent certain ideographs which are used in Chinese, Japanese kanji, and Korean hanja. (Most commonly-used Chinese, kanji, and hanja characters are represented by standard 16-bit Unicode encodings.) Surrogate pairs provide InterSystems IRIS support for the Japanese JIS X0213:2004 (JIS2004) encoding standard and the Chinese GB18030 encoding standard.

A surrogate pair consists of high-order 16-bit character element in the hexadecimal range D800 through DBFF, and a low-order 16-bit character element in the hexadecimal range DC00 through DFFF.

The $WCHAR function treats a surrogate pair as a single character. The $CHAR function treats a surrogate pair as two characters. In all other aspects, $WCHAR and $CHAR are functionally identical. However, because $CHAR is generally faster than $WCHAR, $CHAR is preferable for all cases where a surrogate pair is not likely to be encountered.

For further details on numeric code to character conversion, refer to the $CHAR function.

See Also

FeedbackOpens in a new tab