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 WCSRTOMBS 3 2011-10-16 "GNU" "Linux Programmer's Manual"
18 wcsrtombs \- convert a wide-character string to a multibyte string
23 .BI "size_t wcsrtombs(char *" dest ", const wchar_t **" src ,
24 .BI " size_t " len ", mbstate_t *" ps );
27 If \fIdest\fP is not a NULL pointer,
31 the wide-character string \fI*src\fP to a multibyte string starting at
33 At most \fIlen\fP bytes are written to \fIdest\fP.
36 The conversion is effectively performed by repeatedly
38 .IR "wcrtomb(dest, *src, ps)" ,
39 as long as this call succeeds,
40 and then incrementing \fIdest\fP by the
41 number of bytes written and \fI*src\fP
43 The conversion can stop for three reasons:
45 1. A wide character has been encountered that can not be represented as a
46 multibyte sequence (according to the current locale).
47 In this case \fI*src\fP
48 is left pointing to the invalid wide character,
53 is set to \fBEILSEQ\fP.
55 2. The length limit forces a stop.
56 In this case \fI*src\fP is left pointing
57 to the next wide character to be converted,
58 and the number of bytes written to
59 \fIdest\fP is returned.
61 3. The wide-character string has been completely converted, including the
62 terminating null wide character (L\(aq\\0\(aq),
63 which has the side effect of bringing back \fI*ps\fP
65 In this case \fI*src\fP is set to NULL, and the number
66 of bytes written to \fIdest\fP,
67 excluding the terminating null byte (\(aq\\0\(aq),
70 If \fIdest\fP is NULL, \fIlen\fP is ignored,
71 and the conversion proceeds as above, except that the converted bytes
72 are not written out to memory, and that
73 no length limit exists.
75 In both of the above cases,
76 if \fIps\fP is a NULL pointer, a static anonymous
77 state known only to the
79 function is used instead.
81 The programmer must ensure that there is room for at least \fIlen\fP bytes
87 the number of bytes that make up the
88 converted part of multibyte sequence,
89 not including the terminating null byte.
90 If a wide character was encountered
91 which could not be converted,
106 Passing NULL as \fIps\fP is not multithread safe.