chsvlib
chsv helper source code

◆ ByteLengthUTF8()

std:: size_t Chusov::String::ByteLengthUTF8 ( const char *  pUtf,
std::size_t  cchUtf 
)
noexcept

Returns a number of bytes occupied by the specified number of multibyte symbols of the string specified in the UTF-8 format.

Parameters
[in]pUtfis the string of cchUtf multibyte characters. The string need to be zero-terminated if cchUtf is (size_t) -1.
[in]cchUtfis a size of the string in multibyte characters corresponding to the returned byte size.
Returns
The function returns a number of bytes occupied by the string or (size_t) -1 if an error occurs. Use GetLastChsvError to get extended error information. If the input string contains an invalid multibyte character the error code set is CHSVERROR_INVALID_CHAR_SEQUENCE.
Remarks
If null character is met within cchUtf symbols, then it is ignored together with the rest symbols and bytes.
A value of cchUtf (or the null character) must specify the total number of complete characters in the string. Otherwise the behaviour is undefined.
If the last part of the string contains an incomplete but potentially valid character, it is ignored by the function.