Skip to content

$ZAscii()

$ZAscii()

Returns the numeric byte value (0 through 255) of a given sequence of octets (8-bit bytes).

The format for the $ZASCII function is:

$ZA[SCII](expr[,intexpr])
  • The expression is the sequence of octets (8-bit bytes) from which $ZASCII() extracts the byte it decodes.
  • The optional integer expression contains the position within the expression of the byte that $ZASCII() decodes. If this argument is missing, $ZASCII() returns a result based on the first byte position. $ZASCII() starts numbering byte positions at one (1), (the first byte of a string is at position one (1)).
  • If the explicit or implicit position is before the beginning or after the end of the expression, $ZASCII() returns a value of negative one (-1).
  • $ZASCII() provides a means of examining bytes in a byte sequence. When used with $ZCHAR(), $ZASCII() also provides a means to perform arithmetic operations on the byte values associated with a sequence of octets (8-bit bytes).

Examples of $ZASCII()

Example:

GTM>for i=0:1:4 write !,$zascii("主",i)
 
-1
228
184
187
-1
GTM>

This UTF-8 mode example displays the result of $ZASCII() specifying a byte position before, first, second and third positions, and after the sequence of octets (8-bit bytes) represented by 主. In the above example, 228, 184, and 187 represents the numeric byte value of the three-byte in the sequence of octets (8-bit bytes) represented by 主.