]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/wcsnrtombs.3
Format casts so that there is a non-breaking space after the
[thirdparty/man-pages.git] / man3 / wcsnrtombs.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
3.\" This is free documentation; you can redistribute it and/or
4.\" modify it under the terms of the GNU General Public License as
5.\" published by the Free Software Foundation; either version 2 of
6.\" the License, or (at your option) any later version.
7.\"
8.\" References consulted:
9.\" GNU glibc-2 source code and manual
10.\" Dinkumware C library reference http://www.dinkumware.com/
11.\" OpenGroup's Single Unix specification http://www.UNIX-systems.org/online.html
12.\"
cc4615cc 13.TH WCSNRTOMBS 3 2007-07-26 "GNU" "Linux Programmer's Manual"
fea681da 14.SH NAME
d0f17b57 15wcsnrtombs \- convert a wide-character string to a multibyte string
fea681da
MK
16.SH SYNOPSIS
17.nf
cc4615cc 18.B #define _GNU_SOURCE
fea681da
MK
19.B #include <wchar.h>
20.sp
21.BI "size_t wcsnrtombs(char *" dest ", const wchar_t **" src ", size_t " nwc ,
b9f02710 22.BI " size_t " len ", mbstate_t *" ps );
fea681da
MK
23.fi
24.SH DESCRIPTION
60a90ecd
MK
25The
26.BR wcsnrtombs ()
27function is like the
9daa4fb9 28.BR wcsrtombs (3)
60a90ecd 29function,
c13182ef 30except that the number of wide characters to be converted,
35478399 31starting at \fI*src\fP, is limited to \fInwc\fP.
fea681da 32.PP
c13182ef 33If \fIdest\fP is not a NULL pointer,
60a90ecd
MK
34the
35.BR wcsnrtombs ()
36function converts
fea681da
MK
37at most \fInwc\fP wide characters from
38the wide-character string \fI*src\fP to a multibyte string starting at
c13182ef
MK
39\fIdest\fP.
40At most \fIlen\fP bytes are written to \fIdest\fP.
41The shift state
42\fI*ps\fP is updated.
43The conversion is effectively performed by repeatedly
657e762d 44calling
930d718c 45.IR "wcrtomb(dest, *src, ps)" ,
c13182ef
MK
46as long as this call succeeds,
47and then incrementing \fIdest\fP by the
48number of bytes written and \fI*src\fP
49by one.
50The conversion can stop for three reasons:
fea681da
MK
51.PP
521. A wide character has been encountered that can not be represented as a
c13182ef
MK
53multibyte sequence (according to the current locale).
54In this case \fI*src\fP
7d2cb9d5 55is left pointing to the invalid wide character,
009df872 56.I (size_t)\ \-1
7d2cb9d5 57is returned,
dcec8eb5 58and \fIerrno\fP is set to \fBEILSEQ\fP.
fea681da 59.PP
c13182ef
MK
602. \fInwc\fP wide characters have been
61converted without encountering a L'\\0',
62or the length limit forces a stop.
63In this case \fI*src\fP is left pointing
fea681da
MK
64to the next wide character to be converted, and the number of bytes written
65to \fIdest\fP is returned.
66.PP
673. The wide-character string has been completely converted, including the
68terminating L'\\0' (which has the side effect of bringing back \fI*ps\fP
c13182ef
MK
69to the initial state).
70In this case \fI*src\fP is set to NULL, and the number
fea681da
MK
71of bytes written to \fIdest\fP, excluding the terminating '\\0' byte, is
72returned.
73.PP
c13182ef
MK
74If \fIdest\fP is NULL, \fIlen\fP is ignored,
75and the conversion proceeds as above,
76except that the converted bytes are not written out to memory, and that
fea681da
MK
77no destination length limit exists.
78.PP
c13182ef
MK
79In both of the above cases,
80if \fIps\fP is a NULL pointer, a static anonymous
fea681da
MK
81state only known to the wcsnrtombs function is used instead.
82.PP
83The programmer must ensure that there is room for at least \fIlen\fP bytes
84at \fIdest\fP.
85.SH "RETURN VALUE"
60a90ecd
MK
86The
87.BR wcsnrtombs ()
88function returns
c13182ef
MK
89the number of bytes that make up the
90converted part of multibyte sequence,
91not including the terminating null byte.
92If a wide character was encountered which
7d2cb9d5 93could not be converted,
009df872 94.I (size_t)\ \-1
dcec8eb5 95is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
fea681da
MK
96.SH "CONFORMING TO"
97This function is a GNU extension.
fea681da 98.SH NOTES
d9bfdb9c 99The behavior of
60a90ecd 100.BR wcsnrtombs ()
1274071a
MK
101depends on the
102.B LC_CTYPE
103category of the
fea681da
MK
104current locale.
105.PP
106Passing NULL as \fIps\fP is not multi-thread safe.
e37e3282
MK
107.SH "SEE ALSO"
108.BR iconv (3),
109.BR wcsrtombs (3)