View source code
Display the source code in std/uni.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
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.
Function std.uni.graphemeStride
Computes the length of grapheme cluster starting at index
.
Both the resulting length and the index
are measured
in code units.
size_t graphemeStride(C)
(
scope const C[] input,
size_t index
) pure @safe
if (is(C : dchar));
Parameters
Name | Description |
---|---|
C | type that is implicitly convertible to dchars |
input | array of grapheme clusters |
index | starting index into input[] |
Returns
length of grapheme cluster
Example
writeln(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
writeln(city[0 .. first]); // "A\u030A"
writeln(city[first .. $]); // "rhus"
Authors
Dmitry Olshansky
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.