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