string-length function

The fn:string-length function returns the length of a string.

Syntax

Read syntax diagramSkip visual syntax diagramfn:string-length( source-string)
source-string
The string for which the length is to be returned.

source-string has the xs:string data type, or is an empty sequence.

Returned value

If source-string is not the empty sequence, the returned value is the length of source-string in characters. Code points above xFFFF, which use two 16-bit values known as a surrogate pairs, are counted as one character in the length of the string. source-string is an xs:integer value.

If source-string is the empty sequence, the returned value is 0.

Example

The following function returns the length of the string 'Test literal'.
fn:string-length('Test literal')

The returned value is 12.