]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mbsrtowcs.3
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[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
16mbsrtowcs \- convert a multibyte string to a wide character string
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
e511ffb6 25If \fIdest\fP is not a NULL pointer, the \fBmbsrtowcs\fP() function converts the
fea681da 26multibyte string \fI*src\fP to a wide-character string starting at \fIdest\fP.
c13182ef
MK
27At most \fIlen\fP wide characters are written to \fIdest\fP.
28The shift state
29\fI*ps\fP is updated.
30The conversion is effectively performed by repeatedly
fea681da
MK
31calling mbrtowc(\fIdest\fP,\fI*src\fP,\fIn\fP,\fIps\fP) where \fIn\fP is some
32positive number, as long as this call succeeds, and then incrementing
c13182ef
MK
33\fIdest\fP by one and \fI*src\fP by the number of bytes consumed.
34The conversion can stop for three reasons:
fea681da 35.PP
c13182ef
MK
361. An invalid multibyte sequence has been encountered.
37In this case \fI*src\fP
2bc2f479 38is left pointing to the invalid multibyte sequence, (size_t)(\-1) is returned,
dcec8eb5 39and \fIerrno\fP is set to \fBEILSEQ\fP.
fea681da 40.PP
c13182ef
MK
412. \fIlen\fP non-L'\\0' wide characters have been stored at \fIdest\fP.
42In this
fea681da
MK
43case \fI*src\fP is left pointing to the next multibyte sequence to be converted,
44and the number of wide characters written to \fIdest\fP is returned.
45.PP
463. The multibyte string has been completely converted, including the
47terminating '\\0' (which has the side effect of bringing back \fI*ps\fP to the
c13182ef
MK
48initial state).
49In this case \fI*src\fP is set to NULL, and the number of wide
fea681da
MK
50characters written to \fIdest\fP, excluding the terminating L'\\0' character,
51is returned.
52.PP
53If \fIdest\fP is NULL, \fIlen\fP is ignored, and the conversion proceeds as
54above, except that the converted wide characters are not written out to memory,
55and that no length limit exists.
56.PP
57In both of the above cases, if \fIps\fP is a NULL pointer, a static anonymous
58state only known to the mbsrtowcs function is used instead.
59.PP
60The programmer must ensure that there is room for at least \fIlen\fP wide
61characters at \fIdest\fP.
62.SH "RETURN VALUE"
e511ffb6 63The \fBmbsrtowcs\fP() function returns the number of wide characters that make
fea681da 64up the converted part of the wide character string, not including the
c13182ef
MK
65terminating null wide character.
66If an invalid multibyte sequence was
dcec8eb5 67encountered, (size_t)(\-1) is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
fea681da 68.SH "CONFORMING TO"
68e1685c 69C99
fea681da
MK
70.SH "SEE ALSO"
71.BR iconv (3),
72.BR mbsnrtowcs (3),
73.BR mbstowcs (3)
74.SH NOTES
e511ffb6 75The behaviour of \fBmbsrtowcs\fP() depends on the LC_CTYPE category of the
fea681da
MK
76current locale.
77.PP
78Passing NULL as \fIps\fP is not multi-thread safe.