Advance past valid UTF-8 code points in a string_view.
Declared in <bdlde_utf8util.h>
static
Utf8Util::IntPtr
advanceIfValid(
int* status,
char const** result,
std::string_view const& string,
IntPtr numCodePoints);
Advance past 0 or more consecutive valid Unicode code points at the beginning of the specified string, until either the specified numCodePoints bytes or the whole string have been traversed, or invalid UTF-8 is encountered (whichever occurs first), and return the number of Unicode code points traversed. Set the specified *status to 0 if no invalid UTF-8 is encountered, and to a value from the ErrorStatus enum otherwise. Set the specified *result to the address of the byte immediately following the last valid code point traversed, or to string if its length or numCodePoints is 0. string need not be null-terminated and can contain embedded null bytes. The behavior is undefined unless 0 <= numCodePoints. Note that the value returned will be in the range [0 .. numCodePoints]. Also note that string may contain less than string.length() Unicode code points.
number of Unicode code points traversed
| Name | Description |
|---|---|
| status | receives 0 on success, or an ErrorStatus value |
| result | receives address after the last valid code point |
| string | UTF-8 string view to advance through |
| numCodePoints | maximum number of code points to advance |