This language bar is your friend. Select your favorite languages!

Idiom #169 String length

Assign to integer n the number of characters of string s.

This can be different from the number of bytes of s.

Illustration
uses LazUtf8;
n := Utf8Length(s);
uses sysutils;
n := s.length;
uses LazUtf8;
n := length(s);
size_t n = s.length;
std.range;
size_t n = s.walkLength;
import std.uni, std.range;
size_t n = s.byGrapheme.walkLength;
int n = s.length;
n = String.length s
import "unicode/utf8"
n := utf8.RuneCountInString(s)
n = length s
var n = s.length;
int n = s.length();
local n = utf8.len(s)
$n = mb_strlen($s, 'UTF-8');
my $n = length( $s );
n = len(s)
n = s.size
n = s.length
let n = s.chars().count();

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org