CHAR_LENGTH: Returning the Length in Characters of a String

How to:

The CHAR_LENGTH function returns the length, in characters, of a string. In Unicode environments, this function uses character semantics, so that the length in characters may not be the same as the length in bytes. If the string includes trailing blanks, these are counted in the returned length. Therefore, if the format source string is type An, the returned value will always be n.

Syntax: How to Return the Length of a String in Characters

CHAR_LENGTH(string)

where:

string

Alphanumeric

Is the string whose length is returned.

The data type of the returned length value is Integer.

Example: Returning the Length of a String

LASTNAME has format A15V and contains the last name with trailing blanks removed. CHAR_LENGTH returns the number of characters:

CHAR_LENGTH(LASTNAME)

For SMITH, the result is 5.

WebFOCUS

Feedback