The OpenD Programming Language

byGrapheme

Iterate a string by Grapheme.

Useful for doing string manipulation that needs to be aware of graphemes.

version(!std_uni_bootstrap)
byGrapheme
(
Range
)
(
Range range
)
if (
isInputRange!Range &&
is(immutable ElementType!Range == immutable dchar)
)

Examples

import std.algorithm.comparison : equal;
import std.range.primitives : walkLength;
import std.range : take, drop;
auto text = "noe\u0308l"; // noël using e + combining diaeresis
assert(text.walkLength == 5); // 5 code points

auto gText = text.byGrapheme;
assert(gText.walkLength == 4); // 4 graphemes

assert(gText.take(3).equal("noe\u0308".byGrapheme));
assert(gText.drop(3).equal("l".byGrapheme));

See Also

Meta