Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

wcrtomb(3) [netbsd man page]

WCRTOMB(3)						   BSD Library Functions Manual 						WCRTOMB(3)

NAME
wcrtomb -- converts a wide character to a multibyte character (restartable) LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <wchar.h> size_t wcrtomb(char * restrict s, wchar_t wc, mbstate_t * restrict ps); DESCRIPTION
wcrtomb() converts the wide character given by wc to the corresponding multibyte character, and stores it in the array pointed to by s unless s is a null pointer. This function will modify the first at most MB_CUR_MAX bytes of the array pointed to by s. The behaviour of wcrtomb() is affected by the LC_CTYPE category of the current locale. These are the special cases: wc == 0 For state-dependent encodings, wcrtomb() stores a nul byte preceded by special byte sequence (if any) to return to an initial state in the array pointed to by s, and the state object pointed to by ps also returns to an initial state. s == NULL wcrtomb() just places ps into an initial state. It is equivalent to the following call: wcrtomb(buf, L'', ps); Here, buf is a dummy buffer. In this case, wc is ignored. ps == NULL mbrtowc() uses its own internal state object to keep the conversion state, instead of ps mentioned in this manual page. Calling any other functions in Standard C Library (libc, -lc) never changes the internal state of mbrtowc(), which is initial- ized at startup time of the program. RETURN VALUES
wcrtomb() returns: positive The number of bytes (including any shift sequences) which are stored in the array. (size_t)-1 wc is not a valid wide character. In this case, wcrtomb() also sets errno to indicate the error. ERRORS
wcrtomb() may cause an error in the following case: [EILSEQ] wc is not a valid wide character. [EINVAL] ps points to an invalid or uninitialized mbstate_t object. SEE ALSO
setlocale(3), wctomb(3) STANDARDS
The wcrtomb() function conforms to ISO/IEC 9899/AMD1:1995 (``ISO C90, Amendment 1''). The restrict qualifier is added at ISO/IEC 9899:1999 (``ISO C99''). BSD
February 4, 2002 BSD

Check Out this Related Man Page

WCRTOMB(3)						     Linux Programmer's Manual							WCRTOMB(3)

NAME
wcrtomb - convert a wide character to a multibyte sequence SYNOPSIS
#include <wchar.h> size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps); DESCRIPTION
The main case for this function is when s is not NULL and wc is not L''. In this case, the wcrtomb() function converts the wide charac- ter 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 L''. 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 '' 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. A third case is when s is NULL. In this case wc is ignored, and the function effectively returns wcrtomb(buf,L'',ps) where buf is an internal anonymous buffer. In all of the above cases, if ps is a NULL pointer, a static anonymous state only known to the wcrtomb() function is used instead. RETURN VALUE
The wcrtomb() function returns the number of bytes that have been or would have been written to the byte array at s. If wc can not be rep- resented as a multibyte sequence (according to the current locale), (size_t) -1 is returned, and errno set to EILSEQ. CONFORMING TO
C99. NOTES
The behavior of wcrtomb() depends on the LC_CTYPE category of the current locale. Passing NULL as ps is not multithread safe. SEE ALSO
wcsrtombs(3) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
1999-07-25 WCRTOMB(3)
Man Page