]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/wcsnrtombs.3
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man3 / wcsnrtombs.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 9.\"
4c1c5274 10.TH wcsnrtombs 3 (date) "Linux man-pages (unreleased)"
fea681da 11.SH NAME
d0f17b57 12wcsnrtombs \- convert a wide-character string to a multibyte string
9593c48f
AC
13.SH LIBRARY
14Standard C library
8fc3b2cf 15.RI ( libc ", " \-lc )
fea681da
MK
16.SH SYNOPSIS
17.nf
18.B #include <wchar.h>
68e4db0a 19.PP
c37f316d
AC
20.BI "size_t wcsnrtombs(char *restrict " dest ", const wchar_t **restrict " src ,
21.BI " size_t " nwc ", size_t " len \
22", mbstate_t *restrict " ps );
fea681da 23.fi
68e4db0a 24.PP
d39ad78f 25.RS -4
7dbff9b4
MK
26Feature Test Macro Requirements for glibc (see
27.BR feature_test_macros (7)):
d39ad78f 28.RE
68e4db0a 29.PP
7dbff9b4 30.BR wcsnrtombs ():
9d2adbae
MK
31.nf
32 Since glibc 2.10:
5c10d2c5 33 _POSIX_C_SOURCE >= 200809L
9d2adbae
MK
34 Before glibc 2.10:
35 _GNU_SOURCE
36.fi
fea681da 37.SH DESCRIPTION
60a90ecd
MK
38The
39.BR wcsnrtombs ()
40function is like the
9daa4fb9 41.BR wcsrtombs (3)
60a90ecd 42function,
c13182ef 43except that the number of wide characters to be converted,
40aa0db0
MK
44starting at
45.IR *src ,
46is limited to
47.IR nwc .
fea681da 48.PP
40aa0db0
MK
49If
50.I dest
b437fdd9 51is not NULL,
60a90ecd
MK
52the
53.BR wcsnrtombs ()
54function converts
40aa0db0
MK
55at most
56.I nwc
57wide characters from
58the wide-character string
59.I *src
60to a multibyte string starting at
61.IR dest .
62At most
63.I len
64bytes are written to
65.IR dest .
c13182ef 66The shift state
40aa0db0
MK
67.I *ps
68is updated.
c13182ef 69The conversion is effectively performed by repeatedly
657e762d 70calling
930d718c 71.IR "wcrtomb(dest, *src, ps)" ,
c13182ef 72as long as this call succeeds,
40aa0db0
MK
73and then incrementing
74.I dest
75by the
76number of bytes written and
77.I *src
c13182ef
MK
78by one.
79The conversion can stop for three reasons:
22356d97 80.IP \(bu 3
7fc50d4a 81A wide character has been encountered that can not be represented as a
c13182ef 82multibyte sequence (according to the current locale).
d38ff9af 83In this case,
40aa0db0 84.I *src
7d2cb9d5 85is left pointing to the invalid wide character,
009df872 86.I (size_t)\ \-1
7d2cb9d5 87is returned,
40aa0db0
MK
88and
89.I errno
90is set to
91.BR EILSEQ .
22356d97 92.IP \(bu
40aa0db0
MK
93.I nwc
94wide characters have been
d1a71985 95converted without encountering a null wide character (L\(aq\e0\(aq),
c13182ef 96or the length limit forces a stop.
d38ff9af 97In this case,
40aa0db0
MK
98.I *src
99is left pointing
fea681da 100to the next wide character to be converted, and the number of bytes written
40aa0db0
MK
101to
102.I dest
103is returned.
22356d97 104.IP \(bu
7fc50d4a 105The wide-character string has been completely converted, including the
40aa0db0
MK
106terminating null wide character (which has the side effect of bringing back
107.I *ps
c13182ef 108to the initial state).
d38ff9af 109In this case,
40aa0db0
MK
110.I *src
111is set to NULL, and the number
112of bytes written to
113.IR dest ,
d1a71985 114excluding the terminating null byte (\(aq\e0\(aq), is
fea681da
MK
115returned.
116.PP
40aa0db0 117If
1ae6b2c7 118.I dest
40aa0db0
MK
119is NULL,
120.I len
121is ignored,
c13182ef
MK
122and the conversion proceeds as above,
123except that the converted bytes are not written out to memory, and that
fea681da
MK
124no destination length limit exists.
125.PP
c13182ef 126In both of the above cases,
40aa0db0
MK
127if
128.I ps
b437fdd9 129is NULL, a static anonymous
33a0ccb2 130state known only to the
1c008960
MK
131.BR wcsnrtombs ()
132function is used instead.
fea681da 133.PP
40aa0db0
MK
134The programmer must ensure that there is room for at least
135.I len
136bytes
137at
138.IR dest .
47297adb 139.SH RETURN VALUE
60a90ecd
MK
140The
141.BR wcsnrtombs ()
142function returns
c13182ef
MK
143the number of bytes that make up the
144converted part of multibyte sequence,
3c81e148 145not including the terminating null byte.
c13182ef 146If a wide character was encountered which
7d2cb9d5 147could not be converted,
009df872 148.I (size_t)\ \-1
40aa0db0
MK
149is returned, and
150.I errno
151set to
152.BR EILSEQ .
6d4209de
ZL
153.SH ATTRIBUTES
154For an explanation of the terms used in this section, see
155.BR attributes (7).
c466875e
MK
156.ad l
157.nh
6d4209de
ZL
158.TS
159allbox;
b32feea5 160lb lb lbx
6d4209de
ZL
161l l l.
162Interface Attribute Value
163T{
164.BR wcsnrtombs ()
b32feea5
MK
165T} Thread safety T{
166MT-Unsafe race:wcsnrtombs/!ps
167T}
6d4209de 168.TE
c466875e
MK
169.hy
170.ad
847e0d88 171.sp 1
3113c7f3 172.SH STANDARDS
d9a8bda4 173POSIX.1-2008.
fea681da 174.SH NOTES
d9bfdb9c 175The behavior of
60a90ecd 176.BR wcsnrtombs ()
1274071a
MK
177depends on the
178.B LC_CTYPE
179category of the
fea681da
MK
180current locale.
181.PP
40aa0db0
MK
182Passing NULL as
183.I ps
184is not multithread safe.
47297adb 185.SH SEE ALSO
e37e3282 186.BR iconv (3),
4670051b 187.BR mbsinit (3),
e37e3282 188.BR wcsrtombs (3)