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