Returns the integer ASCII code for a character in the given string. For a mumps process started in UTF-8 mode, $ASCII() returns the integer Unicode® UTF-8 code-point value of a character in the given string.
The format for the $ASCII function is:
$A[SCII](expr[,intexpr])
The expression is the source string from which $ASCII() extracts the character it decodes.
intexpr contains the position within the expression of the character that $ASCII() decodes. If intexpr is missing, $ASCII() returns a result based on the first character position.
If intexpr evaluates to before the beginning or after the end of the expression, $ASCII() returns a value of negative one (-1).
$ASCII() provides a means of examining non-graphic characters in a string. When used with $CHAR(), $ASCII() also provides a means to perform arithmetic operations on the codes associated with characters.
$ZASCII() is the parallel function of $ASCII(). $ZASCII() interprets the string argument as a sequence of bytes (rather than a sequence of characters) and can perform all byte-oriented $ASCII() operations. For more information, refer to “$ZAscii()”.
Example:
GTM>For i=0:1:3 Write !,$Ascii("Hi",i) -1 72 73 -1 GTM>
This loop displays the result of $ASCII() specifying a character position before, first and second positions, and after the string.
Example:
GTM>Write $ZCHSET
UTF-8
GTM>Write $Ascii("主")
20027
GTM>Write $$FUNC^%DH("20027")
00004E3B
In this example, 20027 is the integer equivalent of the hexadecimal value 4E3B. U+4E3B is a character in the CJK Ideograph block of the Unicode® standard.