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