]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mbsrtowcs.3
man*/: ffix (un-bracket tables)
[thirdparty/man-pages.git] / man3 / mbsrtowcs.3
CommitLineData
a1eaacb1 1'\" t
fea681da
MK
2.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
3.\"
e4a74ca8 4.\" SPDX-License-Identifier: GPL-2.0-or-later
fea681da
MK
5.\"
6.\" References consulted:
7.\" GNU glibc-2 source code and manual
8.\" Dinkumware C library reference http://www.dinkumware.com/
008f1ecc 9.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
fea681da
MK
10.\" ISO/IEC 9899:1999
11.\"
4c1c5274 12.TH mbsrtowcs 3 (date) "Linux man-pages (unreleased)"
fea681da 13.SH NAME
d0f17b57 14mbsrtowcs \- convert a multibyte string to a wide-character string
14cd5e25
AC
15.SH LIBRARY
16Standard C library
8fc3b2cf 17.RI ( libc ", " \-lc )
fea681da
MK
18.SH SYNOPSIS
19.nf
20.B #include <wchar.h>
68e4db0a 21.PP
1eed67e7 22.BI "size_t mbsrtowcs(wchar_t " dest "[restrict ." len "], const char **restrict " src ,
b4a5b818 23.BI " size_t " len ", mbstate_t *restrict " ps );
fea681da
MK
24.fi
25.SH DESCRIPTION
40aa0db0
MK
26If
27.I dest
b437fdd9 28is not NULL, the
60a90ecd
MK
29.BR mbsrtowcs ()
30function converts the
40aa0db0
MK
31multibyte string
32.I *src
33to a wide-character string starting at
34.IR dest .
35At most
36.I len
37wide characters are written to
38.IR dest .
c13182ef 39The shift state
40aa0db0
MK
40.I *ps
41is updated.
c13182ef 42The conversion is effectively performed by repeatedly
657e762d 43calling
0daa9e92 44.I "mbrtowc(dest, *src, n, ps)"
40aa0db0
MK
45where
46.I n
47is some
fea681da 48positive number, as long as this call succeeds, and then incrementing
40aa0db0
MK
49.I dest
50by one and
51.I *src
52by the number of bytes consumed.
c13182ef 53The conversion can stop for three reasons:
cdede5cd 54.IP \[bu] 3
bce5f0ae 55An invalid multibyte sequence has been encountered.
d99f93e8 56In this case,
40aa0db0 57.I *src
7d2cb9d5 58is left pointing to the invalid multibyte sequence,
009df872 59.I (size_t)\ \-1
7d2cb9d5 60is returned,
40aa0db0
MK
61and
62.I errno
63is set to
64.BR EILSEQ .
cdede5cd 65.IP \[bu]
40aa0db0 66.I len
b957f81f 67non-L\[aq]\e0\[aq] wide characters have been stored at
40aa0db0 68.IR dest .
d7e98586 69In this case,
40aa0db0
MK
70.I *src
71is left pointing to the next
d9a10d9d 72multibyte sequence to be converted,
40aa0db0
MK
73and the number of wide characters written to
74.I dest
75is returned.
cdede5cd 76.IP \[bu]
bce5f0ae 77The multibyte string has been completely converted, including the
b957f81f 78terminating null wide character (\[aq]\e0\[aq]), which has the side
40aa0db0
MK
79effect of bringing back
80.I *ps
81to the
e9c23bc6 82initial state.
d99f93e8 83In this case,
40aa0db0
MK
84.I *src
85is set to NULL, and the number of wide
86characters written to
87.IR dest ,
e9c23bc6 88excluding the terminating null wide character, is returned.
fea681da 89.PP
40aa0db0 90If
1ae6b2c7 91.I dest
40aa0db0
MK
92is NULL,
93.I len
94is ignored,
d9a10d9d
MK
95and the conversion proceeds as above,
96except that the converted wide characters are not written out to memory,
fea681da
MK
97and that no length limit exists.
98.PP
d9a10d9d 99In both of the above cases,
40aa0db0
MK
100if
101.I ps
b437fdd9 102is NULL, a static anonymous
33a0ccb2 103state known only to the
d9a10d9d
MK
104.BR mbsrtowcs ()
105function is used instead.
fea681da 106.PP
40aa0db0
MK
107The programmer must ensure that there is room for at least
108.I len
109wide
110characters at
111.IR dest .
47297adb 112.SH RETURN VALUE
60a90ecd
MK
113The
114.BR mbsrtowcs ()
115function returns the number of wide characters that make
d0f17b57 116up the converted part of the wide-character string, not including the
c13182ef
MK
117terminating null wide character.
118If an invalid multibyte sequence was
7d2cb9d5 119encountered,
009df872 120.I (size_t)\ \-1
40aa0db0
MK
121is returned, and
122.I errno
123set to
124.BR EILSEQ .
03c07cb1
ZL
125.SH ATTRIBUTES
126For an explanation of the terms used in this section, see
127.BR attributes (7).
128.TS
129allbox;
b32feea5 130lb lb lbx
03c07cb1
ZL
131l l l.
132Interface Attribute Value
133T{
9e54434e
BR
134.na
135.nh
03c07cb1 136.BR mbsrtowcs ()
b32feea5 137T} Thread safety T{
9e54434e
BR
138.na
139.nh
b32feea5
MK
140MT-Unsafe race:mbsrtowcs/!ps
141T}
03c07cb1 142.TE
847e0d88 143.sp 1
3113c7f3 144.SH STANDARDS
4131356c
AC
145C11, POSIX.1-2008.
146.SH HISTORY
147POSIX.1-2001, C99.
fea681da 148.SH NOTES
d9bfdb9c 149The behavior of
60a90ecd 150.BR mbsrtowcs ()
1274071a
MK
151depends on the
152.B LC_CTYPE
153category of the
fea681da
MK
154current locale.
155.PP
40aa0db0
MK
156Passing NULL as
157.I ps
158is not multithread safe.
47297adb 159.SH SEE ALSO
e37e3282 160.BR iconv (3),
9247e95b 161.BR mbrtowc (3),
65789f05 162.BR mbsinit (3),
e37e3282
MK
163.BR mbsnrtowcs (3),
164.BR mbstowcs (3)