mbrtowc function — Converts a multibyte character to a wide character
size_t mbrtowc(wchar_t* pwc, const char* str, size_t n, mbstate_t* ps)
The mbrtowc
function
converts a multibyte character to a wide character. First, it counts
the number of bytes needed to complete the next multibyte character
that str
points to. At most,
n
bytes of str
are examined. If str
points to a valid multibyte character,
that character is converted to a wide character, which is stored in
*pwc
.
The ps
parameter points to
the shift state, which keeps track of the conversion state between
calls to mbrtowc
. If ps
is a null pointer, an internal shift
state is used (which is similar to calling mbtowc
in <cstdlib>
).
The return value is one of the following:
0
If the multibyte character represents the null wide character
static_cast<size_t>(-1)
If str
does not point
to a valid multibyte character
static_cast<size_t>(-2)
If n
is too
small
If the multibyte character is valid, in which case the value returned is the number of bytes in the multibyte character