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.strideBack
Calculate the length of the UTF sequence ending one code unit before
index
in str
.
uint strideBack(S)
(
auto ref S str,
size_t index
)
if (is(S : const(char[])) || isRandomAccessRange!S && is(Unqual!(ElementType!S) == char));
uint strideBack(S)
(
auto ref S str
)
if (is(S : const(char[])) || isRandomAccessRange!S && hasLength!S && is(Unqual!(ElementType!S) == char));
uint strideBack(S)
(
auto ref S str
)
if (isBidirectionalRange!S && is(Unqual!(ElementType!S) == char) && !isRandomAccessRange!S);
uint strideBack(S)
(
auto ref S str,
size_t index
)
if (is(S : const(wchar[])) || isRandomAccessRange!S && is(Unqual!(ElementType!S) == wchar));
uint strideBack(S)
(
auto ref S str
)
if (is(S : const(wchar[])) || isBidirectionalRange!S && is(Unqual!(ElementType!S) == wchar));
uint strideBack(S)
(
auto ref S str,
size_t index
)
if (isRandomAccessRange!S && is(Unqual!(ElementEncodingType!S) == dchar));
uint strideBack(S)
(
auto ref S str
)
if (isBidirectionalRange!S && is(Unqual!(ElementEncodingType!S) == dchar));
Parameters
Name | Description |
---|---|
str | bidirectional range of UTF code units. Must be random access if
index is passed |
index | index one past end of UTF sequence (default: str ) |
Returns
The number of code units in the UTF sequence. For UTF-8, this is a value between 1 and 4 (as per RFC 3629, section 3). For UTF-16, it is either 1 or 2. For UTF-32, it is always 1.
Throws
May throw a UTFException
if str[index]
is not one past the
end of a valid UTF sequence.
Note
strideBack
will only analyze the element at str[index - 1]
element. It will not fully verify the validity of the UTF sequence, nor
even verify the presence of the sequence: it will not actually
guarantee that strideBack(str, index) <= index
.
Example
writeln("a" .strideBack); // 1
writeln("λ" .strideBack); // 2
writeln("aλ" .strideBack); // 2
writeln("aλ" .strideBack(1)); // 1
writeln("𐐷" .strideBack); // 4
Authors
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.