1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
3 .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
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.
10 .\" References consulted:
11 .\" GNU glibc-2 source code and manual
12 .\" Dinkumware C library reference http://www.dinkumware.com/
13 .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
16 .TH MBSRTOWCS 3 2011-09-28 "GNU" "Linux Programmer's Manual"
18 mbsrtowcs \- convert a multibyte string to a wide-character string
23 .BI "size_t mbsrtowcs(wchar_t *" dest ", const char **" src ,
24 .BI " size_t " len ", mbstate_t *" ps );
27 If \fIdest\fP is not a NULL pointer, the
30 multibyte string \fI*src\fP to a wide-character string starting at \fIdest\fP.
31 At most \fIlen\fP wide characters are written to \fIdest\fP.
34 The conversion is effectively performed by repeatedly
36 .I "mbrtowc(dest, *src, n, ps)"
38 positive number, as long as this call succeeds, and then incrementing
39 \fIdest\fP by one and \fI*src\fP by the number of bytes consumed.
40 The conversion can stop for three reasons:
42 An invalid multibyte sequence has been encountered.
43 In this case \fI*src\fP
44 is left pointing to the invalid multibyte sequence,
47 and \fIerrno\fP is set to \fBEILSEQ\fP.
49 \fIlen\fP non-L\(aq\\0\(aq wide characters have been stored at \fIdest\fP.
51 case \fI*src\fP is left pointing to the next
52 multibyte sequence to be converted,
53 and the number of wide characters written to \fIdest\fP is returned.
55 The multibyte string has been completely converted, including the
56 terminating null wide character (\(aq\\0\(aq), which has the side
57 effect of bringing back \fI*ps\fP to the
59 In this case \fI*src\fP is set to NULL, and the number of wide
60 characters written to \fIdest\fP,
61 excluding the terminating null wide character, is returned.
63 If \fIdest\fP is NULL, \fIlen\fP is ignored,
64 and the conversion proceeds as above,
65 except that the converted wide characters are not written out to memory,
66 and that no length limit exists.
68 In both of the above cases,
69 if \fIps\fP is a NULL pointer, a static anonymous
70 state known only to the
72 function is used instead.
74 The programmer must ensure that there is room for at least \fIlen\fP wide
75 characters at \fIdest\fP.
79 function returns the number of wide characters that make
80 up the converted part of the wide-character string, not including the
81 terminating null wide character.
82 If an invalid multibyte sequence was
85 is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
96 Passing NULL as \fIps\fP is not multithread safe.