chsvlib
chsv helper source code

◆ CharacterLengthUTF8()

std:: size_t Chusov::String::CharacterLengthUTF8 ( const char *  pszUtf,
std::size_t  cbUtf 
)
noexcept

Returns a number of multibyte symbols that are composed from the specified number of bytes of a string encoded in the UTF-8 format.

Parameters
[in]pszUtfis a pointer to the string. If cbUtf is (size_t) -1 the string must be zero-terminated.
[in]cbUtfis a byte size of the string. The value can be (size_t) -1 if the string is zero-terminated.
Returns
Returns an actual number of multibyte characters described by the bytes of the string in the current codepage. If function fails it returns (size_t) -1 setting corresponding chsvlib error code. If the string contains illegal byte sequence the error code set is CHSVERROR_INVALID_CHAR_SEQUENCE.
Remarks
If the string is null-terminated and the terminating null character is located among cbUtf bytes of the string, it is ignored together with the following symbols.
If the last part of the string contains an incomplete but potentially valid character, it is ignored by the function.