Pointer to a multibyte character sequence to analyze, or `NULL` to check the state-dependency of the current 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.
3rd Parameter Type : mbstate_t *
A pointer to an `mbstate_t` object that represents the current shift state for multibyte to wide character conversions. This pointer allows modification of the state during the conversion process.
3rd Parameter
Pointer to a `mbstate_t` object representing the current conversion state, or `NULL` to use the internal static state.
Read more about parameters of mbrlen in parameters section
The mbrlenfunction in C language Determines the number of bytes in a multibyte character, given state.
The mbrlen function determines the number of bytes constituting the next multibyte character in the string pointed to by s, examining at most n bytes. It uses the conversion state pointed to by ps, or an internal state if ps is NULL. This function is equivalent to mbrtowc(NULL, s, n, ps != NULL ? ps : &internal).
The mbrlenfunction takes 3
parameters:
•
const char * `s`: Pointer to a multibyte character sequence to analyze, or `NULL` to check the state-dependency of the current conversion state.
•
size_t `n`: The maximum number of bytes to examine in the multibyte character sequence.
•
mbstate_t * `ps`: Pointer to a `mbstate_t` object representing the current conversion state, or `NULL` to use the internal static state.
Determines the number of bytes in the next multibyte character in the sequence pointed to by `s`, considering at most `n` bytes and the state in `ps`. Returns the number of bytes in the multibyte character, `0` if the character is null, or `(size_t)-1` for an encoding error. If `s` is `NULL`, it checks if the conversion state is independent, returning `0` or `(size_t)-1`.
The mbrlen function return value :
Returns: 0 if s points to a null character, the number of bytes that constitute the next multibyte character, (size_t)(-2) if the next n bytes contribute to an incomplete (but potentially valid) multibyte character, or (size_t)(-1) if an encoding error occurs
Output
This example demonstrates basic usage of mbrlen to determine the length of each multibyte character in a string.