1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
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.
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
14 .TH MBSRTOWCS 3 1999-07-25 "GNU" "Linux Programmer's Manual"
16 mbsrtowcs \- convert a multibyte string to a wide-character string
21 .BI "size_t mbsrtowcs(wchar_t *" dest ", const char **" src ,
22 .BI " size_t " len ", mbstate_t *" ps );
25 If \fIdest\fP is not a NULL pointer, the
28 multibyte string \fI*src\fP to a wide-character string starting at \fIdest\fP.
29 At most \fIlen\fP wide characters are written to \fIdest\fP.
32 The conversion is effectively performed by repeatedly
34 .I "mbrtowc(dest, *src, n, ps)"
36 positive number, as long as this call succeeds, and then incrementing
37 \fIdest\fP by one and \fI*src\fP by the number of bytes consumed.
38 The conversion can stop for three reasons:
40 1. An invalid multibyte sequence has been encountered.
41 In this case \fI*src\fP
42 is left pointing to the invalid multibyte sequence,
45 and \fIerrno\fP is set to \fBEILSEQ\fP.
47 2. \fIlen\fP non-L'\\0' wide characters have been stored at \fIdest\fP.
49 case \fI*src\fP is left pointing to the next
50 multibyte sequence to be converted,
51 and the number of wide characters written to \fIdest\fP is returned.
53 3. The multibyte string has been completely converted, including the
54 terminating '\\0' (which has the side
55 effect of bringing back \fI*ps\fP to the
57 In this case \fI*src\fP is set to NULL, and the number of wide
58 characters written to \fIdest\fP,
59 excluding the terminating L'\\0' character, is returned.
61 If \fIdest\fP is NULL, \fIlen\fP is ignored,
62 and the conversion proceeds as above,
63 except that the converted wide characters are not written out to memory,
64 and that no length limit exists.
66 In both of the above cases,
67 if \fIps\fP is a NULL pointer, a static anonymous
68 state only known to the
70 function is used instead.
72 The programmer must ensure that there is room for at least \fIlen\fP wide
73 characters at \fIdest\fP.
77 function returns the number of wide characters that make
78 up the converted part of the wide-character string, not including the
79 terminating null wide character.
80 If an invalid multibyte sequence was
83 is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
94 Passing NULL as \fIps\fP is not multi-thread safe.