1WCRTOMB(3)                 Linux Programmer's Manual                WCRTOMB(3)
2
3
4

NAME

6       wcrtomb - convert a wide character to a multibyte sequence
7

SYNOPSIS

9       #include <wchar.h>
10
11       size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps);
12

DESCRIPTION

14       The  main  case for this function is when s is not NULL and wc is not a
15       null wide character (L'\0').  In this case, the wcrtomb() function con‐
16       verts  the wide character wc to its multibyte representation and stores
17       it at the beginning of the character array pointed to by s.  It updates
18       the shift state *ps, and returns the length of said multibyte represen‐
19       tation, that is, the number of bytes written at s.
20
21       A different case is when s is not NULL, but wc is a null wide character
22       (L'\0').   In  this case the wcrtomb() function stores at the character
23       array pointed to by s the shift sequence needed to bring  *ps  back  to
24       the initial state, followed by a '\0' byte.  It updates the shift state
25       *ps (i.e., brings it into the initial state), and returns the length of
26       the shift sequence plus one, that is, the number of bytes written at s.
27
28       A  third  case  is when s is NULL.  In this case wc is ignored, and the
29       function effectively returns
30
31           wcrtomb(buf, L'\0', ps)
32
33       where buf is an internal anonymous buffer.
34
35       In all of the above cases, if ps is a NULL pointer, a static  anonymous
36       state known only to the wcrtomb() function is used instead.
37

RETURN VALUE

39       The  wcrtomb()  function  returns the number of bytes that have been or
40       would have been written to the byte array at s.  If wc can not be  rep‐
41       resented  as  a  multibyte  sequence (according to the current locale),
42       (size_t) -1 is returned, and errno set to EILSEQ.
43

CONFORMING TO

45       C99.
46

NOTES

48       The behavior of wcrtomb() depends on the LC_CTYPE category of the  cur‐
49       rent locale.
50
51       Passing NULL as ps is not multithread safe.
52

SEE ALSO

54       wcsrtombs(3)
55

COLOPHON

57       This  page  is  part of release 3.53 of the Linux man-pages project.  A
58       description of the project, and information about reporting  bugs,  can
59       be found at http://www.kernel.org/doc/man-pages/.
60
61
62
63GNU                               2011-09-28                        WCRTOMB(3)
Impressum