]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/wcsrtombs.3
namespaces.7: ffix
[thirdparty/man-pages.git] / man3 / wcsrtombs.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
89e3ffe9 3.\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
fea681da
MK
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.
fe382ebf 8.\" %%%LICENSE_END
fea681da
MK
9.\"
10.\" References consulted:
11.\" GNU glibc-2 source code and manual
12.\" Dinkumware C library reference http://www.dinkumware.com/
008f1ecc 13.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
fea681da
MK
14.\" ISO/IEC 9899:1999
15.\"
460495ca 16.TH WCSRTOMBS 3 2015-08-08 "GNU" "Linux Programmer's Manual"
fea681da 17.SH NAME
d0f17b57 18wcsrtombs \- convert a wide-character string to a multibyte string
fea681da
MK
19.SH SYNOPSIS
20.nf
21.B #include <wchar.h>
22.sp
23.BI "size_t wcsrtombs(char *" dest ", const wchar_t **" src ,
b9f02710 24.BI " size_t " len ", mbstate_t *" ps );
fea681da
MK
25.fi
26.SH DESCRIPTION
40aa0db0
MK
27If
28.I dest
b437fdd9 29is not NULL,
60a90ecd
MK
30the
31.BR wcsrtombs ()
32function converts
40aa0db0
MK
33the wide-character string
34.I *src
35to a multibyte string starting at
36.IR dest .
37At most
38.I len
39bytes are written to
40.IR dest .
35478399 41The shift state
40aa0db0
MK
42.I *ps
43is updated.
35478399 44The conversion is effectively performed by repeatedly
657e762d
MK
45calling
46.IR "wcrtomb(dest, *src, ps)" ,
35478399 47as long as this call succeeds,
40aa0db0
MK
48and then incrementing
49.I dest
50by the
51number of bytes written and
52.I *src
c13182ef 53by one.
35478399 54The conversion can stop for three reasons:
49d2adfa
MK
55.IP 1. 3
56A wide character has been encountered that can not be represented as a
c13182ef 57multibyte sequence (according to the current locale).
0ce76989 58In this case,
40aa0db0 59.I *src
7d2cb9d5 60is left pointing to the invalid wide character,
009df872 61.I (size_t)\ \-1
7d2cb9d5 62is returned,
fea681da
MK
63and
64.I errno
40aa0db0
MK
65is set to
66.BR EILSEQ .
49d2adfa
MK
67.IP 2.
68The length limit forces a stop.
0ce76989 69In this case,
40aa0db0
MK
70.I *src
71is left pointing
c13182ef
MK
72to the next wide character to be converted,
73and the number of bytes written to
40aa0db0
MK
74.I dest
75is returned.
49d2adfa
MK
76.IP 3.
77The wide-character string has been completely converted, including the
e9c23bc6 78terminating null wide character (L\(aq\\0\(aq),
40aa0db0
MK
79which has the side effect of bringing back
80.I *ps
e9c23bc6 81to the initial state.
0ce76989 82In this case,
40aa0db0
MK
83.I *src
84is set to NULL, and the number
85of bytes written to
86.IR dest ,
3c81e148
MK
87excluding the terminating null byte (\(aq\\0\(aq),
88is returned.
fea681da 89.PP
40aa0db0 90If
51700fd7 91.IR dest
40aa0db0
MK
92is NULL,
93.I len
94is ignored,
c13182ef
MK
95and the conversion proceeds as above, except that the converted bytes
96are not written out to memory, and that
fea681da
MK
97no length limit exists.
98.PP
c13182ef 99In both of the above cases,
40aa0db0
MK
100if
101.I ps
b437fdd9 102is NULL, a static anonymous
33a0ccb2 103state known only to the
c639d151
MK
104.BR wcsrtombs ()
105function is used instead.
fea681da 106.PP
40aa0db0
MK
107The programmer must ensure that there is room for at least
108.I len
109bytes
110at
111.IR dest .
47297adb 112.SH RETURN VALUE
60a90ecd
MK
113The
114.BR wcsrtombs ()
115function returns
c13182ef
MK
116the number of bytes that make up the
117converted part of multibyte sequence,
118not including the terminating null byte.
119If a wide character was encountered
7d2cb9d5 120which could not be converted,
009df872 121.I (size_t)\ \-1
fea681da
MK
122is returned, and
123.I errno
40aa0db0
MK
124set to
125.BR EILSEQ .
652318ee
ZL
126.SH ATTRIBUTES
127For an explanation of the terms used in this section, see
128.BR attributes (7).
129.TS
130allbox;
131lb lb lbw28
132l l l.
133Interface Attribute Value
134T{
135.BR wcsrtombs ()
136T} Thread safety MT-Unsafe race:wcsrtombs/!ps
137.TE
138
47297adb 139.SH CONFORMING TO
8e08c66a 140POSIX.1-2001, POSIX.1-2008, C99.
fea681da 141.SH NOTES
d9bfdb9c 142The behavior of
60a90ecd 143.BR wcsrtombs ()
1274071a
MK
144depends on the
145.B LC_CTYPE
146category of the
fea681da
MK
147current locale.
148.PP
40aa0db0
MK
149Passing NULL as
150.I ps
151is not multithread safe.
47297adb 152.SH SEE ALSO
e37e3282 153.BR iconv (3),
65789f05 154.BR mbsinit (3),
4670051b 155.BR wcrtomb (3),
e37e3282
MK
156.BR wcsnrtombs (3),
157.BR wcstombs (3)