View source code Display the source code in std/utf.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.

std.utf.stride_back - multiple declarations

Function strideBack

strideBack returns the length of the UTF-32 sequence ending one code unit before index in str.

strideBack works with both UTF-32 strings and ranges of dchar. If no index is passed, then a bidirectional range will work, but if an index is passed, then a random-access range is required.

index defaults to str.length if none is passed.

Prototypes

uint strideBack(S)(
  S str,
  size_t index
)
if (isRandomAccessRange!S && is(Unqual!(ElementEncodingType!S) == dchar));

uint strideBack(S)(
  S str
)
if (isBidirectionalRange!S && is(Unqual!(ElementEncodingType!S) == dchar));

Returns

The number of bytes in the UTF-32 sequence (always 1).

Throws

Never.

Function strideBack

strideBack returns the length of the UTF-16 sequence ending one code unit before index in str.

strideBack works with both UTF-16 strings and ranges of wchar. If no index is passed, then a bidirectional range will work, but if an index is passed, then a random-access range is required.

index defaults to str.length if none is passed.

Prototypes

uint strideBack(S)(
  S str,
  size_t index
)
if (is(S : const(wchar[])) || isRandomAccessRange!S && is(Unqual!(ElementType!S) == wchar));

uint strideBack(S)(
  S str
)
if (is(S : const(wchar[])) || isBidirectionalRange!S && is(Unqual!(ElementType!S) == wchar));

Returns

The number of bytes in the UTF-16 sequence.

Throws

May throw a UTFException if str[index] is not one past the end of a valid UTF-16 sequence.

Notes

stride will only analyze the element at str[index - 1] element. It will not fully verify the validity of UTF-16 sequence, nor even verify the presence of the sequence: it will not actually guarantee that stride(str, index) <= index.

Function strideBack

strideBack returns the length of the UTF-8 sequence ending one code unit before index in str.

strideBack works with both UTF-8 strings and bidirectional ranges of char. If no index is passed, then a bidirectional range will work, but if an index is passed, then a random-access range is required.

index defaults to str.length if none is passed.

Prototypes

uint strideBack(S)(
  S str,
  size_t index
)
if (is(S : const(char[])) || isRandomAccessRange!S && is(Unqual!(ElementType!S) == char));

uint strideBack(S)(
  S str
)
if (is(S : const(char[])) || isRandomAccessRange!S && hasLength!S && is(Unqual!(ElementType!S) == char));

Returns

The number of bytes in the UTF-8 sequence.

Throws

May throw a UTFException if str[index] is not one past the end of a valid UTF-8 sequence.

Notes

strideBack will not fully verify the validity of the UTF-8 sequence. It will, however, guarantee that index - stride(str, index) is a valid index.

Authors

Walter Bright and Jonathan M Davis

License

Boost License 1.0.

Comments