[#BloombergLP-bdlde-Utf8Util-numCharactersIfValid-0a] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlde.adoc[bdlde]::xref:BloombergLP/bdlde/Utf8Util.adoc[Utf8Util]::numCharactersIfValid :relfileprefix: ../../../ :mrdocs: Return the Unicode code‐point count if `string` is valid UTF‐8. == Synopsis Declared in `<bdlde_utf8util.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- static xref:BloombergLP/bdlde/Utf8Util/IntPtr.adoc[Utf8Util::IntPtr] numCharactersIfValid( char const** invalidString, char const* string, xref:BloombergLP/bdlde/Utf8Util/size_type.adoc[size_type] length); ---- == Description Otherwise, return a negative value and load into `invalidString` the address of the byte after the last valid Unicode code point traversed. `string` need not be null‐terminated and may contain embedded null bytes, and `string` may be null if `0 == length` (see {Empty Input Strings}). Note that `string` may contain less than `length` Unicode code points. == Return Value code‐point count on success, or a negative value on invalid UTF‐8 == Parameters [cols="1,4"] |=== | Name| Description | *invalidString* | if non‐null, set to the first invalid byte on error | *string* | UTF‐8 byte sequence to examine | *length* | length of `string` in bytes |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#