Skip to main content
Previous sectionNext section

BYTE

Returns the character corresponding to the specified character code.

Synopsis

BYTE(charcode)

Arguments

charcode An expression that resolves to an integer code that identifies a character. For 8-bit characters, the value in charcode must evaluate to a positive integer in the range 0 to 255. For 16-bit characters, specify integers in the range 256 through 65534.

Description

The BYTE function takes a character code and returns the corresponding character. The SEQ function takes a character and returns the corresponding ASCII character code. The charcode must be a positive, base-10 integer. A fractional number is truncated to its integer portion. A negative number, empty string, or non-numeric value returns the empty string.

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

Note:

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

Examples

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

PRINT BYTE(65);    ! Returns A.
PRINT BYTE(97);    ! Returns a.
PRINT BYTE(37);    ! Returns %.
PRINT BYTE(62);    ! Returns >.
Copy code to clipboard

The following example uses the BYTE 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 BYTE(letter)
  letter=letter+1
NEXT
Copy code to clipboard

See Also