]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/wcsnrtombs.3
MB_CUR_MAX.3, MB_LEN_MAX.3, btowc.3, fgetwc.3, fgetws.3, fputwc.3, fputws.3, fwide...
[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.\"
3c81e148 15.TH WCSNRTOMBS 3 2011-10-16 "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>
21.sp
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
7dbff9b4
MK
25.sp
26.in -4n
27Feature Test Macro Requirements for glibc (see
28.BR feature_test_macros (7)):
29.in
30.sp
31.BR wcsnrtombs ():
ea91c3fd
MK
32.PD 0
33.ad l
34.RS 4
35.TP 4
36Since glibc 2.10:
37_XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
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,
35478399 51starting at \fI*src\fP, is limited to \fInwc\fP.
fea681da 52.PP
c13182ef 53If \fIdest\fP is not a NULL pointer,
60a90ecd
MK
54the
55.BR wcsnrtombs ()
56function converts
fea681da
MK
57at most \fInwc\fP wide characters from
58the wide-character string \fI*src\fP to a multibyte string starting at
c13182ef
MK
59\fIdest\fP.
60At most \fIlen\fP bytes are written to \fIdest\fP.
61The shift state
62\fI*ps\fP is updated.
63The conversion is effectively performed by repeatedly
657e762d 64calling
930d718c 65.IR "wcrtomb(dest, *src, ps)" ,
c13182ef
MK
66as long as this call succeeds,
67and then incrementing \fIdest\fP by the
68number of bytes written and \fI*src\fP
69by one.
70The conversion can stop for three reasons:
fea681da
MK
71.PP
721. A wide character has been encountered that can not be represented as a
c13182ef
MK
73multibyte sequence (according to the current locale).
74In this case \fI*src\fP
7d2cb9d5 75is left pointing to the invalid wide character,
009df872 76.I (size_t)\ \-1
7d2cb9d5 77is returned,
dcec8eb5 78and \fIerrno\fP is set to \fBEILSEQ\fP.
fea681da 79.PP
c13182ef 802. \fInwc\fP wide characters have been
e9c23bc6 81converted without encountering a null wide character (L\(aq\\0\(aq),
c13182ef
MK
82or the length limit forces a stop.
83In this case \fI*src\fP is left pointing
fea681da
MK
84to the next wide character to be converted, and the number of bytes written
85to \fIdest\fP is returned.
86.PP
873. The wide-character string has been completely converted, including the
e9c23bc6 88terminating null wide character (which has the side effect of bringing back \fI*ps\fP
c13182ef
MK
89to the initial state).
90In this case \fI*src\fP is set to NULL, and the number
3c81e148
MK
91of bytes written to \fIdest\fP,
92excluding the terminating null byte (\(aq\\0\(aq), is
fea681da
MK
93returned.
94.PP
c13182ef
MK
95If \fIdest\fP is NULL, \fIlen\fP is ignored,
96and the conversion proceeds as above,
97except that the converted bytes are not written out to memory, and that
fea681da
MK
98no destination length limit exists.
99.PP
c13182ef
MK
100In both of the above cases,
101if \fIps\fP is a NULL pointer, a static anonymous
fea681da
MK
102state only known to the wcsnrtombs function is used instead.
103.PP
104The programmer must ensure that there is room for at least \fIlen\fP bytes
105at \fIdest\fP.
47297adb 106.SH RETURN VALUE
60a90ecd
MK
107The
108.BR wcsnrtombs ()
109function returns
c13182ef
MK
110the number of bytes that make up the
111converted part of multibyte sequence,
3c81e148 112not including the terminating null byte.
c13182ef 113If a wide character was encountered which
7d2cb9d5 114could not be converted,
009df872 115.I (size_t)\ \-1
dcec8eb5 116is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
47297adb 117.SH CONFORMING TO
d9a8bda4 118POSIX.1-2008.
fea681da 119.SH NOTES
d9bfdb9c 120The behavior of
60a90ecd 121.BR wcsnrtombs ()
1274071a
MK
122depends on the
123.B LC_CTYPE
124category of the
fea681da
MK
125current locale.
126.PP
71fea607 127Passing NULL as \fIps\fP is not multithread safe.
47297adb 128.SH SEE ALSO
e37e3282
MK
129.BR iconv (3),
130.BR wcsrtombs (3)