[#BloombergLP-bdlde-Utf8Util-advanceIfValid-0e]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlde.adoc[bdlde]::xref:BloombergLP/bdlde/Utf8Util.adoc[Utf8Util]::advanceIfValid
:relfileprefix: ../../../
:mrdocs:

Advance past valid UTF&hyphen;8 code points in `string`&period;

== Synopsis

Declared in `&lt;bdlde&lowbar;utf8util&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
static
xref:BloombergLP/bdlde/Utf8Util/IntPtr.adoc[IntPtr]
advanceIfValid(
    int* status,
    char const** result,
    char const* string,
    xref:BloombergLP/bdlde/Utf8Util/IntPtr.adoc[IntPtr] numCodePoints);
----

== Description

Advance past 0 or more consecutive _valid_ Unicode code points at the beginning of the specified `string`, until either the specified `numCodePoints` have been traversed, or the terminating null byte or invalid UTF&hyphen;8 is encountered (whichever occurs first), and return the number of Unicode code points traversed&period; Set the specified `&ast;status` to 0 if no invalid UTF&hyphen;8 is encountered, and to a value from the `ErrorStatus` `enum` otherwise&period; Set the specified `&ast;result` to the address of the byte immediately following the last valid code point traversed, or to `string` if `string` is empty or `numCodePoints` is 0&period; `string` is necessarily null&hyphen;terminated, so it cannot contain embedded null bytes&period; The behavior is undefined unless `0 &lt;&equals; numCodePoints`&period; Note that the value returned will be in the range `&lsqb;0 &period;&period; numCodePoints&rsqb;`&period; Also note that `string` may contain less than `bsl&colon;&colon;strlen(string)` Unicode code points&period;

== Return Value

number of Unicode code points traversed

== Parameters

[cols="1,4"]
|===
| Name| Description
| *status*
| receives 0 on success, or an `ErrorStatus` value
| *result*
| receives address after the last valid code point
| *string*
| null&hyphen;terminated UTF&hyphen;8 input
| *numCodePoints*
| maximum number of code points to advance
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
