The mbtowc function

Name

mbtowc -- 

Synopsis

#include <stdlib.h>

int mbtowc (wchar_t *pwc, const char *s, size_t n);

Description

If s is not a null pointer, the mbtowc function determines the number of bytes in the multi-byte character pointer to by s. It then determines the code for the value of type wchar_t that corresponds to the multi-byte character. I the multi-byte character is valid and pwc is not a null pointer then mbtowc stores the code in the object pointer to by pwc. At most n bytes of the array pointed to by s will be examined.

The implementation shall behave as if no library function calls th mbtowc function.

Returns

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

In no case will the value returned be greater than n or the value of the MB_CUR_MAX macro.

See Also

The wctomb function

Implementation Notes

None