View source code
Display the source code in std/utf.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.utf.toUCSindex
Given index
into str
and assuming that index
is at the start
of a UTF sequence, toUCSindex
determines the number of UCS characters
up to index
. So, index
is the index of a code unit at the
beginning of a code point, and the return value is how many code points into
the string that that code point is.
size_t toUCSindex(C)
(
const(C)[] str,
size_t index
) pure @safe
if (isSomeChar!C);
Example
writeln(toUCSindex(`hello world`, 7)); // 7
writeln(toUCSindex(`hello world`w, 7)); // 7
writeln(toUCSindex(`hello world`d, 7)); // 7
writeln(toUCSindex(`Ma Chérie`, 7)); // 6
writeln(toUCSindex(`Ma Chérie`w, 7)); // 7
writeln(toUCSindex(`Ma Chérie`d, 7)); // 7
writeln(toUCSindex(`さいごの果実 / ミツバチと科学者`, 9)); // 3
writeln(toUCSindex(`さいごの果実 / ミツバチと科学者`w, 9)); // 9
writeln(toUCSindex(`さいごの果実 / ミツバチと科学者`d, 9)); // 9
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.