]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mbsrtowcs.3
membarrier.2: Remove redundant mention of return value of MEMBARRIER_CMD_SHARED
[thirdparty/man-pages.git] / man3 / mbsrtowcs.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
MK
14.\" ISO/IEC 9899:1999
15.\"
460495ca 16.TH MBSRTOWCS 3 2015-08-08 "GNU" "Linux Programmer's Manual"
fea681da 17.SH NAME
d0f17b57 18mbsrtowcs \- convert a multibyte string to a wide-character string
fea681da
MK
19.SH SYNOPSIS
20.nf
21.B #include <wchar.h>
22.sp
23.BI "size_t mbsrtowcs(wchar_t *" dest ", const char **" src ,
24.BI " size_t " len ", mbstate_t *" ps );
25.fi
26.SH DESCRIPTION
40aa0db0
MK
27If
28.I dest
b437fdd9 29is not NULL, the
60a90ecd
MK
30.BR mbsrtowcs ()
31function converts the
40aa0db0
MK
32multibyte string
33.I *src
34to a wide-character string starting at
35.IR dest .
36At most
37.I len
38wide characters are written to
39.IR dest .
c13182ef 40The shift state
40aa0db0
MK
41.I *ps
42is updated.
c13182ef 43The conversion is effectively performed by repeatedly
657e762d 44calling
0daa9e92 45.I "mbrtowc(dest, *src, n, ps)"
40aa0db0
MK
46where
47.I n
48is some
fea681da 49positive number, as long as this call succeeds, and then incrementing
40aa0db0
MK
50.I dest
51by one and
52.I *src
53by the number of bytes consumed.
c13182ef 54The conversion can stop for three reasons:
bce5f0ae
MK
55.IP 1. 3
56An invalid multibyte sequence has been encountered.
d99f93e8 57In this case,
40aa0db0 58.I *src
7d2cb9d5 59is left pointing to the invalid multibyte sequence,
009df872 60.I (size_t)\ \-1
7d2cb9d5 61is returned,
40aa0db0
MK
62and
63.I errno
64is set to
65.BR EILSEQ .
bce5f0ae 66.IP 2.
40aa0db0
MK
67.I len
68non-L\(aq\\0\(aq wide characters have been stored at
69.IR dest .
d7e98586 70In this case,
40aa0db0
MK
71.I *src
72is left pointing to the next
d9a10d9d 73multibyte sequence to be converted,
40aa0db0
MK
74and the number of wide characters written to
75.I dest
76is returned.
bce5f0ae
MK
77.IP 3.
78The multibyte string has been completely converted, including the
e9c23bc6 79terminating null wide character (\(aq\\0\(aq), which has the side
40aa0db0
MK
80effect of bringing back
81.I *ps
82to the
e9c23bc6 83initial state.
d99f93e8 84In this case,
40aa0db0
MK
85.I *src
86is set to NULL, and the number of wide
87characters written to
88.IR dest ,
e9c23bc6 89excluding the terminating null wide character, is returned.
fea681da 90.PP
40aa0db0 91If
51700fd7 92.IR dest
40aa0db0
MK
93is NULL,
94.I len
95is ignored,
d9a10d9d
MK
96and the conversion proceeds as above,
97except that the converted wide characters are not written out to memory,
fea681da
MK
98and that no length limit exists.
99.PP
d9a10d9d 100In both of the above cases,
40aa0db0
MK
101if
102.I ps
b437fdd9 103is NULL, a static anonymous
33a0ccb2 104state known only to the
d9a10d9d
MK
105.BR mbsrtowcs ()
106function is used instead.
fea681da 107.PP
40aa0db0
MK
108The programmer must ensure that there is room for at least
109.I len
110wide
111characters at
112.IR dest .
47297adb 113.SH RETURN VALUE
60a90ecd
MK
114The
115.BR mbsrtowcs ()
116function returns the number of wide characters that make
d0f17b57 117up the converted part of the wide-character string, not including the
c13182ef
MK
118terminating null wide character.
119If an invalid multibyte sequence was
7d2cb9d5 120encountered,
009df872 121.I (size_t)\ \-1
40aa0db0
MK
122is returned, and
123.I errno
124set to
125.BR EILSEQ .
03c07cb1
ZL
126.SH ATTRIBUTES
127For an explanation of the terms used in this section, see
128.BR attributes (7).
129.TS
130allbox;
131lb lb lbw28
132l l l.
133Interface Attribute Value
134T{
135.BR mbsrtowcs ()
136T} Thread safety MT-Unsafe race:mbsrtowcs/!ps
137.TE
138
47297adb 139.SH CONFORMING TO
765c9ca2 140POSIX.1-2001, POSIX.1-2008, C99.
fea681da 141.SH NOTES
d9bfdb9c 142The behavior of
60a90ecd 143.BR mbsrtowcs ()
1274071a
MK
144depends on the
145.B LC_CTYPE
146category of the
fea681da
MK
147current locale.
148.PP
40aa0db0
MK
149Passing NULL as
150.I ps
151is not multithread safe.
47297adb 152.SH SEE ALSO
e37e3282 153.BR iconv (3),
9247e95b 154.BR mbrtowc (3),
65789f05 155.BR mbsinit (3),
e37e3282
MK
156.BR mbsnrtowcs (3),
157.BR mbstowcs (3)