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 WCSRTOMBS 3 1999-07-25 "GNU" "Linux Programmer's Manual"
16 wcsrtombs \- convert a wide-character string to a multibyte string
21 .BI "size_t wcsrtombs(char *" dest ", const wchar_t **" src ,
22 .BI " size_t " len ", mbstate_t *" ps );
25 If \fIdest\fP is not a NULL pointer,
29 the wide-character string \fI*src\fP to a multibyte string starting at
31 At most \fIlen\fP bytes are written to \fIdest\fP.
34 The conversion is effectively performed by repeatedly
36 .IR "wcrtomb(dest, *src, ps)" ,
37 as long as this call succeeds,
38 and then incrementing \fIdest\fP by the
39 number of bytes written and \fI*src\fP
41 The conversion can stop for three reasons:
43 1. A wide character has been encountered that can not be represented as a
44 multibyte sequence (according to the current locale).
45 In this case \fI*src\fP
46 is left pointing to the invalid wide character,
51 is set to \fBEILSEQ\fP.
53 2. The length limit forces a stop.
54 In this case \fI*src\fP is left pointing
55 to the next wide character to be converted,
56 and the number of bytes written to
57 \fIdest\fP is returned.
59 3. The wide-character string has been completely converted, including the
60 terminating L'\\0' (which has the side effect of bringing back \fI*ps\fP
61 to the initial state).
62 In this case \fI*src\fP is set to NULL, and the number
63 of bytes written to \fIdest\fP, excluding the terminating '\\0' byte, is
66 If \fIdest\fP is NULL, \fIlen\fP is ignored,
67 and the conversion proceeds as above, except that the converted bytes
68 are not written out to memory, and that
69 no length limit exists.
71 In both of the above cases,
72 if \fIps\fP is a NULL pointer, a static anonymous
73 state only known to the wcsrtombs function is used instead.
75 The programmer must ensure that there is room for at least \fIlen\fP bytes
81 the number of bytes that make up the
82 converted part of multibyte sequence,
83 not including the terminating null byte.
84 If a wide character was encountered
85 which could not be converted,
100 Passing NULL as \fIps\fP is not multi-thread safe.