chsvlib
chsv helper source code

◆ CharacterLengthMBS()

std:: size_t Chusov::String::CharacterLengthMBS ( const char *  pszString,
std::size_t  cbInput 
)
noexcept

Returns a number of multibyte symbols that are specified by the cbInput bytes of the pszString encoded as defined by the current locale.

Parameters
[in]pszStringis a pointer to the string. If cbInput is (size_t) -1 the string must be zero-terminated.
[in]cbInputis 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 code page. 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 cbInput 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.