mbtowc(3) Library Functions Manual mbtowc(3) mbtowc - C (libc, -lc) #include int mbtowc(size_t size; wchar_t *restrict pwc, const char s[restrict size], size_t size); The main case for this function is when s is not NULL and pwc is not NULL. In this case, the mbtowc() function inspects at most size bytes of the multibyte string starting at s, extracts the next complete multibyte character, converts it to a wide character and stores it at *pwc. It updates an internal shift state known only to the mbtowc() function. If s does not point to a null byte ('\0'), it returns the number of bytes that were consumed from s, otherwise it returns 0. If the size bytes starting at s do not contain a complete multibyte character, or if they contain an invalid multibyte sequence, mbtowc() returns -1. This can happen even if size >= MB_CUR_MAX, if the multibyte string contains redundant shift sequences. , s NULL, pwc NULL. mbtowc() , . A third case is when s is NULL. In this case, pwc and size are ignored. The mbtowc() function 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. s NULL, mbtowc() , s, 0, s null, -1 -- . s NULL, mbtowc() , , , . attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |mbtowc() | | MT-Unsafe race | +----------------------------+----------------------------------------------------------+--------------------------+ . mbrtowc(3) . C11, POSIX.1-2008. POSIX.1-2001, C99. mbtowc() LC_CTYPE . MB_CUR_MAX(3), mblen(3), mbrtowc(3), mbstowcs(3), wcstombs(3), wctomb(3) () aereiae , Alexey , Azamat Hackimov , Dmitriy S. Seregin , Dmitry Bolkhovskikh , ITriskTI , Max Is , Yuri Kozlov , ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () . Linux man-pages 6.18 8 2026 . mbtowc(3)