[#BloombergLP-bdlde-Utf8Util-numCodePointsIfValid-09]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlde.adoc[bdlde]::xref:BloombergLP/bdlde/Utf8Util.adoc[Utf8Util]::numCodePointsIfValid
:relfileprefix: ../../../
:mrdocs:

Return the Unicode code&hyphen;point count if a bounded `string` is valid&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]
numCodePointsIfValid(
    char const** invalidString,
    char const* string,
    xref:BloombergLP/bdlde/Utf8Util/size_type.adoc[size&lowbar;type] length);
----

== Description

Return the number of Unicode code points in the specified `string` having the specified `length` (in bytes) if `string` contains valid UTF&hyphen;8, with no effect on the specified `invalidString`&period; Otherwise, return a value from the `ErrorStatus` `enum` (which are all negative) and load into `invalidString` the address of the byte after the last valid Unicode code point traversed&period; `string` need not be null&hyphen;terminated and may contain embedded null bytes, and `string` may be null if `0 &equals;&equals; length` (see &lcub;Empty Input Strings&rcub;)&period; Note that `string` may contain less than `length` Unicode code points&period;

== Return Value

code&hyphen;point count on success, or an `ErrorStatus` value

== Parameters

[cols="1,4"]
|===
| Name| Description
| *invalidString*
| if non&hyphen;null, set to after the last valid code point
| *string*
| UTF&hyphen;8 byte sequence (need not be null&hyphen;terminated)
| *length*
| length of `string` in bytes
|===


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