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)
#include <string>
int n = s.length();
size_t n = s.length;
size_t n = s.walkLength;
import std.uni, std.range;
size_t n = s.byGrapheme.walkLength;
int n = s.length;
n = String.length s
n = length s
var n = s.length;
int n = s.length();
local n = utf8.len(s)
uses LazUtf8;
n := length(s);
uses sysutils;
n := s.length;
uses LazUtf8;
n := Utf8Length(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