The mblen function

Name

mblen -- 

Synopsis

#include <stdlib.h>

int mblen (const char *s, size_t n);

Description

If s is not a null pointer, the mblen function determines the number of bytes contained in the multi-byte character pointed to by s. Except that the shift state of the mbtowc function is not affected, it is equivalent to

mbtowc((wchar_t *)0, s, n);
The implementation shall behave as if no library function calls the mblen function.

Returns

If s is a null pointer, the mblen function returns a non-zero or zero value, if multi-byte encodings, respectively, do or do not have state-dependent encodings. If s is not a null pointer, the mblen function either returns 0 (if s points to the null character) or returns the number of bytes that are contained in the multi-byte character (if the next n or fewer bytes form a multi-byte character), or returns -1 (if they do not form a valid multi-byte character).

See Also

The mbtowc function

Implementation Notes

In GCC-1750 all characters occupy one byte (which is 16 bits) and state-dependent encodings are not supported.
If s is a null pointer or if s points to the null character then mblen will return zero. Otherwise if s points to a valid multi-byte character (n >= 1), then mblen will return 1. Otherwise mblen will return -1.