411 REFERENCE · Wikibooks
C programming/wchar.h/mbrlen
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
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.
Need
To use this function in program one include the standard header file<wchar.h>.
Syntax
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.
Return value
(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 character, 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 .
Sources
http://pubs.opengroup.org/onlinepubs/9699919799/functions/mbrlen.html .
http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=/com.qnx.doc.neutrino_lib_re/m/mbrlen.html.
http://publib.boulder.ibm.com/infocenter/pseries/v5r3/topic/com.ibm.aix.basetechref/doc/basetrf1/mbrlen.htm.
deep