Skip to content

Latest commit

 

History

History
77 lines (52 loc) · 1.84 KB

strlen-function.md

File metadata and controls

77 lines (52 loc) · 1.84 KB
title description ms.reviewer ms.topic ms.date
strlen()
Learn how to use the strlen() function to measure the length of the input string.
alexans
reference
02/05/2023

strlen()

Returns the length, in characters, of the input string.

Note

This function counts Unicode code points.

Syntax

strlen(source)

[!INCLUDE syntax-conventions-note]

Parameters

Name Type Required Description
source string ✔️ The string for which to return the length.

Returns

Returns the length, in characters, of the input string.

Examples

String of letters

[!div class="nextstepaction"] Run the query

print length = strlen("hello")

Output

length
5

String of letters and symbols

[!div class="nextstepaction"] Run the query

print length = strlen("⒦⒰⒮⒯⒪")

Output

length
5

String with grapheme

[!div class="nextstepaction"] Run the query

print strlen('Çedilla') // the first character is a grapheme cluster
                        // that requires 2 code points to represent

Output

length
8