BloombergLP::bdlde::Utf8Util::numCharactersIfValid

Return the Unicode code-point count if string is valid UTF-8.

Synopsis

Declared in <bdlde_utf8util.h>

static
Utf8Util::IntPtr
numCharactersIfValid(
    char const** invalidString,
    char const* string);

Description

Return the number of Unicode code points in the specified string if it contains valid UTF-8, with no effect on the specified invalidString. Otherwise, return a negative value and load into invalidString the address of the byte after the last valid Unicode code point traversed. string is necessarily null-terminated, so it cannot contain embedded null bytes. Note that string may contain less than bsl::strlen(string) Unicode code points.

DEPRECATED: Use numCodePointsIfValid instead.

Return Value

code-point count on success, or a negative value on invalid UTF-8

Parameters

NameDescription
invalidStringif non-null, set to after the last valid code point
stringnull-terminated UTF-8 input to examine