]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mbsrtowcs.3
Format casts so that there is a non-breaking space after the
[thirdparty/man-pages.git] / man3 / mbsrtowcs.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.\" ISO/IEC 9899:1999
13.\"
14.TH MBSRTOWCS 3 1999-07-25 "GNU" "Linux Programmer's Manual"
15.SH NAME
d0f17b57 16mbsrtowcs \- convert a multibyte string to a wide-character string
fea681da
MK
17.SH SYNOPSIS
18.nf
19.B #include <wchar.h>
20.sp
21.BI "size_t mbsrtowcs(wchar_t *" dest ", const char **" src ,
22.BI " size_t " len ", mbstate_t *" ps );
23.fi
24.SH DESCRIPTION
60a90ecd
MK
25If \fIdest\fP is not a NULL pointer, the
26.BR mbsrtowcs ()
27function converts the
fea681da 28multibyte string \fI*src\fP to a wide-character string starting at \fIdest\fP.
c13182ef
MK
29At most \fIlen\fP wide characters are written to \fIdest\fP.
30The shift state
31\fI*ps\fP is updated.
32The conversion is effectively performed by repeatedly
657e762d 33calling
0daa9e92 34.I "mbrtowc(dest, *src, n, ps)"
657e762d 35where \fIn\fP is some
fea681da 36positive number, as long as this call succeeds, and then incrementing
c13182ef
MK
37\fIdest\fP by one and \fI*src\fP by the number of bytes consumed.
38The conversion can stop for three reasons:
fea681da 39.PP
c13182ef
MK
401. An invalid multibyte sequence has been encountered.
41In this case \fI*src\fP
7d2cb9d5 42is left pointing to the invalid multibyte sequence,
009df872 43.I (size_t)\ \-1
7d2cb9d5 44is returned,
dcec8eb5 45and \fIerrno\fP is set to \fBEILSEQ\fP.
fea681da 46.PP
c13182ef
MK
472. \fIlen\fP non-L'\\0' wide characters have been stored at \fIdest\fP.
48In this
d9a10d9d
MK
49case \fI*src\fP is left pointing to the next
50multibyte sequence to be converted,
fea681da
MK
51and the number of wide characters written to \fIdest\fP is returned.
52.PP
533. The multibyte string has been completely converted, including the
d9a10d9d
MK
54terminating '\\0' (which has the side
55effect of bringing back \fI*ps\fP to the
c13182ef
MK
56initial state).
57In this case \fI*src\fP is set to NULL, and the number of wide
d9a10d9d
MK
58characters written to \fIdest\fP,
59excluding the terminating L'\\0' character, is returned.
fea681da 60.PP
d9a10d9d
MK
61If \fIdest\fP is NULL, \fIlen\fP is ignored,
62and the conversion proceeds as above,
63except that the converted wide characters are not written out to memory,
fea681da
MK
64and that no length limit exists.
65.PP
d9a10d9d
MK
66In both of the above cases,
67if \fIps\fP is a NULL pointer, a static anonymous
68state only known to the
69.BR mbsrtowcs ()
70function is used instead.
fea681da
MK
71.PP
72The programmer must ensure that there is room for at least \fIlen\fP wide
73characters at \fIdest\fP.
74.SH "RETURN VALUE"
60a90ecd
MK
75The
76.BR mbsrtowcs ()
77function returns the number of wide characters that make
d0f17b57 78up the converted part of the wide-character string, not including the
c13182ef
MK
79terminating null wide character.
80If an invalid multibyte sequence was
7d2cb9d5 81encountered,
009df872 82.I (size_t)\ \-1
7d2cb9d5 83is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
fea681da 84.SH "CONFORMING TO"
68e1685c 85C99
fea681da 86.SH NOTES
d9bfdb9c 87The behavior of
60a90ecd 88.BR mbsrtowcs ()
1274071a
MK
89depends on the
90.B LC_CTYPE
91category of the
fea681da
MK
92current locale.
93.PP
94Passing NULL as \fIps\fP is not multi-thread safe.
e37e3282
MK
95.SH "SEE ALSO"
96.BR iconv (3),
97.BR mbsnrtowcs (3),
98.BR mbstowcs (3)