chsvlib
chsv helper source code

◆ ByteLengthMBS()

std:: size_t Chusov::String::ByteLengthMBS ( const char *  pszString,
std::size_t  cchInput 
)
noexcept

Returns a number of bytes occupied by the cchInput multibyte symbols of a string.

Parameters
[in]pszStringis the string of cchInput multibyte characters. The string need not to be zero-terminated unless cchInput is (size_t) -1.
[in]cchInputis 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 error occurs. Use GetLastChsvError to get extended 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 cchInput symbols, then it is ignored together with the rest symbols and bytes.
cchInput (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.