Section: Linux Programmer's Manual (3)
Return to Main Contents
mbtowc - convert a multibyte sequence to a wide character
int mbtowc(wchar_t *pwc, const char *s, size_t n);
The main case for this function is when
is not NULL and
In this case, the
function inspects at most
bytes of the multibyte string starting at
extracts the next complete
multibyte character, converts it to a wide character and stores it at
It updates an internal shift state known only to the
does not point to a null byte ('\0'), it returns the number
of bytes that were consumed from
otherwise it returns 0.
bytes starting at
do not contain a complete multibyte
character, or if they contain an invalid multibyte sequence,
This can happen even if
if the multibyte string contains redundant shift sequences.
A different case is when
is not NULL but
function behaves as above, except that it does not
store the converted wide character in memory.
A third case is when
In this case,
resets the shift state, only known to this function,
to the initial state, and
returns nonzero if the encoding has nontrivial shift state, or zero if the
encoding is stateless.
is not NULL, the
function returns the number of
consumed bytes starting at
or 0 if
points to a null byte,
or -1 upon failure.
is NULL, the
returns nonzero if the encoding
has nontrivial shift state, or zero if the encoding is stateless.
The behavior of
depends on the
category of the
This function is not multithread safe.
a better interface to the same functionality.
This page is part of release 3.54 of the Linux
A description of the project,
and information about reporting bugs,
can be found at
- RETURN VALUE
- CONFORMING TO
- SEE ALSO
This document was created by
using the manual pages.
Time: 02:16:36 GMT, January 22, 2018