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.

import "unicode/utf8"
n := utf8.RuneCountInString(s)
int n = s.length;
var n = s.length;
int n = s.length();
uses LazUtf8;
n := length(s); //single byte encoding or widestring, plain pascal
n := Utf8Length(s); //UTF8-encoding, as used in Lazarus
n = s.length

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

Idiom created by