A pointer to the multibyte character to be analyzed. If `s` is `NULL`, the function resets the conversion state.
2nd Parameter Type : size_t
Platform-specific unsigned type for array indices and memory sizes.
2nd Parameter
The maximum number of bytes to examine in the multibyte character sequence.
Read more about parameters of mblen in parameters section
The mblenfunction in C language Returns the number of bytes in the next multibyte character.
The mblen function determines the number of bytes contained in the multibyte character pointed to by s, examining at most n bytes. If s is a null pointer, the mblen function resets the shift state to the initial shift state. The behavior of this function is affected by the LC_CTYPE category of the current locale.
The mblenfunction takes 2
parameters:
•
const char * `s`: A pointer to the multibyte character to be analyzed. If `s` is `NULL`, the function resets the conversion state.
•
size_t `n`: The maximum number of bytes to examine in the multibyte character sequence.
Determines the number of bytes in the multibyte character pointed to by `s`, considering at most `n` bytes. Returns the length of the multibyte character in bytes, 0 if `s` points to the null character, or -1 if the multibyte sequence is invalid. If `s` is `NULL`, the function resets the internal conversion state and returns 0 if multibyte characters are state-independent.
The mblen function return value :
If s is not a null pointer, the mblen function returns: 0 if s points to a null byte, the number of bytes that constitute the next multibyte character, or -1 if the next n bytes do not form a valid multibyte character
If s is a null pointer, the mblen function returns a nonzero value if multibyte character encodings have state-dependent encodings, and zero otherwise
Output
This example demonstrates basic usage of mblen to determine the length of each multibyte character in a string.