View source code
Display the source code in std/uni.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.uni.graphemeStride
Computes the length of grapheme cluster starting at
.
Both the resulting length and the index
are measured
in Code unit, code units.
index
Prototype
size_t graphemeStride(C)( C[] input, size_t index ) if (is(C : dchar));
Parameters
Name | Description |
---|---|
C | type that is implicitly convertible to dchars |
input | array of grapheme clusters |
index | starting index into
|
Returns
length of grapheme cluster
Example
// ASCII as usual is 1 code unit, 1 code point etc. assert(graphemeStride(" ", 1) == 1); // A + combing ring above string city = "A\u030Arhus"; size_t first = graphemeStride(city, 0); assert(first == 3); //\u030A has 2 UTF-8 code units assert(city[0..first] == "A\u030A"); assert(city[first..$] == "rhus");
Authors
Dmitry Olshansky