Logo

Programming-Idioms

History of Idiom 169 > diff from v19 to v20

Edit summary for version 20 by programming-idioms.org:
[D] No need to declare s in code

Version 19

2018-02-04, 16:58:56

Version 20

2018-02-05, 11:19:33

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.

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.

Extra Keywords
size
Extra Keywords
size
Imports
import std.uni, std.range;
Imports
import std.uni, std.range;
Code
string s;
size_t n = s.byGrapheme.walkLength;
Code
size_t n = s.byGrapheme.walkLength;
Comments bubble
n is the count of graphic characters.
Comments bubble
n is the count of graphic characters.