[phobos] UTF-8 string slicing
Masahiro Nakagawa
repeatedly at gmail.com
Fri Aug 19 11:42:38 PDT 2011
On Sat, 20 Aug 2011 02:24:41 +0900, unDEFER <undefer at gmail.com> wrote:
[snip]
> The fact which the next code
> ----
> writeln( arr.length );
> arr.popFront();
> writeln( arr.length );
> ----
> prints 9 after 10 for any array but for UTF-8 and UTF-16 strings may
> print as well 8 or lesser, seems too confusing for me.
You can use std.algorithm.count to count the number of elements.
assert([1,2,3].count() == 3);
assert("abc".count() == 3);
assert("あいう".count() == 3);
More information about the phobos
mailing list