mbrlen is the standard library function used to determine the length of the multi-byte character using conversion state . The mbrlen function differ from 'mblen' 'mblen l' by its restartability.
To use this function in program one include the standrad header file<wchar.h>.
size_t mbrlen (const char *s, size_t maxsize, mbstate_t *ps ).
the mbrlen() function inspects at most maxsize of the string pointed i.e. s and extracts the next complete multibyte character . It updates the shift state *ps .If the multibyte character is not the NULL wide character , it returns the number of the bytes that were consumed by s.
(size_t) - 2 : the resulting conversion state indicates an incomplete multibyte character after all maxsize character were converted .
(size_t) - 1 : the function detected an encoding error before completing the next multibyte chracter , in which case the function errno to EILSEQ amd leaves the resulting conversion state undefined.
0 : the next complete character is a null character , in which case the resulting conversion state is the initial conversion state .
positive : if the next n or fewer byte complete a valid character ; the value returned shall be the number of bytes that complete the character .