Return the Unicode code‐point count if a bounded string is valid.

Synopsis

Declared in <bdlde_utf8util.h>

static
IntPtr
numCodePointsIfValid(
    char const** invalidString,
    char const* string,
    size_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‐8, with no effect on the specified invalidString. 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. 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 an ErrorStatus value

Parameters

Name

Description

invalidString

if non‐null, set to after the last valid code point

string

UTF‐8 byte sequence (need not be null‐terminated)

length

length of string in bytes

Created with MrDocs