wcrtomb(3) Library Functions Manual wcrtomb(3) wcrtomb - LIBRARY Standard C library (libc, -lc) #include size_t wcrtomb(char *restrict s, wchar_t wc, mbstate_t *restrict ps); The main case for this function is when s is not NULL and wc is not a null wide character (L'\0'). In this case, the wcrtomb() function converts the wide character wc to its multibyte representation and stores it at the beginning of the character array pointed to by s. It updates the shift state *ps, and returns the length of said multibyte representation, that is, the number of bytes written at s. A different case is when s is not NULL, but wc is a null wide character (L'\0'). In this case, the wcrtomb() function stores at the character array pointed to by s the shift sequence needed to bring *ps back to the initial state, followed by a '\0' byte. It updates the shift state *ps (i.e., brings it into the initial state), and returns the length of the shift sequence plus one, that is, the number of bytes written at s. -- s NULL. wc , wcrtomb(buf, L'\0', ps) buf -- . , ps NULL, , wcrtomb(). wcrtomb() , , s. wc ( ), (size_t) -1, errno EILSEQ. attributes(7). +----------------------------+----------------------------------------------------------+----------------------------+ | | | | +----------------------------+----------------------------------------------------------+----------------------------+ |wcrtomb() | | MT-Unsafe race:wcrtomb/!ps | +----------------------------+----------------------------------------------------------+----------------------------+ C11, POSIX.1-2008. POSIX.1-2001, C99. wcrtomb() LC_CTYPE . NULL ps . . mbsinit(3), wcsrtombs(3) Azamat Hackimov Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . wcrtomb(3)