StringByteLength

Description

Returns the number of bytes in a string for a given charset. It is sometimes useful to know the number of bytes needed to represent a string with multi-byte character sets (for example: UTF-8 or WindowsJapanese). A string with UTF-8 charset can use up to 4 bytes to represent a character.

Syntax

StringByteLength ( str,charset)

Arguments

str is a string expression

charset is a string representing the charset (MapBasic or Java)

Both arguments are required.

Example

Returns 32 because the eight Japanese characters use four bytes each when using UTF-32.
select StringByteLength("滋賀県草津市草津", "UTF-32") 

Remarks

If a non-string value is passed for str or charset, an error is thrown.

If an invalid charset (including an empty string) is passed for charset, an error is thrown.