MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / utf8_find_nth

Method utf8_find_nth

include/stringzilla/stringzilla.hpp:4191–4197  ·  view source on GitHub ↗

* @brief Find the byte offset of the nth UTF-8 character. * @param n The character index (0-based). * @return The byte offset, or npos if n >= character count. */

Source from the content-addressed store, hash-verified

4189 * @return The byte offset, or npos if n >= character count.
4190 */
4191 size_type utf8_find_nth(size_type n) const noexcept {
4192 sz_ptr_t start;
4193 sz_size_t length;
4194 sz_string_range(&string_, &start, &length);
4195 auto ptr = sz_utf8_find_nth(start, length, n);
4196 return ptr ? ptr - start : npos;
4197 }
4198
4199 /**
4200 * @brief Iterate over UTF-8 characters (codepoints) in the string.

Callers 2

sz_utf8_find_nthFunction · 0.45

Calls 2

sz_string_rangeFunction · 0.85
sz_utf8_find_nthFunction · 0.70

Tested by

no test coverage detected