byteLen()

The strLib.byteLen() system function returns the number of bytes in a variable, excluding any trailing spaces and null values.

In contrast, strLib.characterLen() returns the number of characters rather than the number of bytes. See "Example" in this topic.

Syntax

  strLib.byteLen(source CHAR | MBCHAR | DBCHAR | UNICODE in)
  returns (result INT)
source
A character variable that matches one of the types shown.
result
An INT that gives the length of the variable in bytes. For DBCHAR, UNICODE, and typically for MBCHAR types, the number of bytes is greater than the number of characters.

Compatibility considerations

Table 1. Compatibility considerations
Platform Issue
JavaScript generation The function strLib.byteLen() is not supported.

Example

  myUnicode5 UNICODE(5) = "ABC";
  length INT;

  length = strLib.byteLen(myUnicode5); // length=6
  length = strLib.characterLen(myUnicode5); // length=3  

Feedback