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 - multiple declarations

Function stride

stride returns the length of the UTF-32 sequence starting at index in str.

stride works with both UTF-32 strings and ranges of dchar.

Prototype

uint stride(S)(
  S str,
  size_t index = 0
)
if (is(S : const(dchar[])) || isInputRange!S && is(Unqual!(ElementEncodingType!S) == dchar));

Returns

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

Throws

Never.

Function stride

stride returns the length of the UTF-16 sequence starting at index in str.

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

index defaults to 0 if none is passed.

Prototypes

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

uint stride(S)(
  S str
) pure @safe
if (is(S : const(wchar[])));

Returns

The number of bytes in the UTF-16 sequence.

Throws

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

Notes

stride will only analyze the first str[index] 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 index + stride(str, index) <= str.length.

Function stride

stride returns the length of the UTF-8 sequence starting at index in str.

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

index defaults to 0 if none is passed.

Prototypes

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

uint stride(S)(
  S str
)
if (is(S : const(char[])) || isInputRange!S && is(Unqual!(ElementType!S) == char));

Returns

The number of bytes in the UTF-8 sequence, a value between 1 and 4 (as per RFC 3629).

Throws

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

Notes

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

Authors

Walter Bright and Jonathan M Davis

License

Boost License 1.0.

Comments