1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
8 .\" References consulted:
9 .\" GNU glibc-2 source code and manual
10 .\" Dinkumware C library reference http://www.dinkumware.com/
11 .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
14 .TH WCRTOMB 3 2011-09-28 "GNU" "Linux Programmer's Manual"
16 wcrtomb \- convert a wide character to a multibyte sequence
21 .BI "size_t wcrtomb(char *" s ", wchar_t " wc ", mbstate_t *" ps );
24 The main case for this function is when \fIs\fP is
25 not NULL and \fIwc\fP is not a null wide character (L\(aq\\0\(aq).
29 converts the wide character \fIwc\fP
30 to its multibyte representation and stores it
31 at the beginning of the character
32 array pointed to by \fIs\fP.
33 It updates the shift state \fI*ps\fP, and
34 returns the length of said multibyte representation,
35 that is, the number of bytes
38 A different case is when \fIs\fP is not NULL,
39 but \fIwc\fP is a null wide character (L\(aq\\0\(aq).
44 the character array pointed to by
45 \fIs\fP the shift sequence needed to
46 bring \fI*ps\fP back to the initial state,
47 followed by a \(aq\\0\(aq byte.
48 It updates the shift state \fI*ps\fP (i.e., brings
49 it into the initial state),
50 and returns the length of the shift sequence plus
51 one, that is, the number of bytes written at \fIs\fP.
53 A third case is when \fIs\fP is NULL.
54 In this case \fIwc\fP is ignored,
55 and the function effectively returns
57 wcrtomb(buf, L\(aq\\0\(aq, ps)
61 is an internal anonymous buffer.
63 In all of the above cases, if \fIps\fP is a NULL pointer, a static anonymous
64 state only known to the
66 function is used instead.
70 function returns the number of
71 bytes that have been or would
72 have been written to the byte array at \fIs\fP.
73 If \fIwc\fP can not be
74 represented as a multibyte sequence (according to the current locale),
76 is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
87 Passing NULL as \fIps\fP is not multithread safe.