Skip to main content


Returns the number of bytes in a string.




string An expression that resolves to a string or number.


The BYTELEN function returns the number of bytes in a specified string. BYTELEN counts bytes. Therefore, on a Unicode implementation of Caché each character is counted as 2 bytes; a Unicode instance of Caché counts two bytes per character even when string contain no Unicode characters. Use the LEN function to count characters, rather than bytes.

For numerics, prior to determining the length MVBasic performs all arithmetic operations and converts numbers to canonical form, with leading and trailing zeroes, a trailing decimal point, and all signs removed except a single minus sign. Note that BYTELEN does count the decimal point and the minus sign. Numeric strings are not converted to canonical form. An empty string ("") returns a length of 0.


The following example uses the BYTELEN function to return the number of bytes in a string on a Unicode system:

PRINT BYTELEN("InterSystems");  ! Returns 24
PRINT BYTELEN(+0099.900);       ! Returns 8
PRINT BYTELEN("0099.900");      ! Returns 16
PRINT BYTELEN(CHAR(960));       ! Returns 2
PRINT BYTELEN("");              ! Returns 0

See Also

FeedbackOpens in a new tab