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
13 .TH MBSNRTOWCS 3 2011-10-01 "GNU" "Linux Programmer's Manual"
15 mbsnrtowcs \- convert a multibyte string to a wide-character string
20 .BI "size_t mbsnrtowcs(wchar_t *" dest ", const char **" src ,
21 .BI " size_t " nms ", size_t " len ", mbstate_t *" ps );
25 Feature Test Macro Requirements for glibc (see
26 .BR feature_test_macros (7)):
35 _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L
48 the number of bytes to be converted, starting at \fI*src\fP, is limited to
51 If \fIdest\fP is not a NULL pointer, the
54 most \fInms\fP bytes from the
55 multibyte string \fI*src\fP to a wide-character string starting at \fIdest\fP.
56 At most \fIlen\fP wide characters are written to \fIdest\fP.
59 The conversion is effectively performed by repeatedly
61 .I "mbrtowc(dest, *src, n, ps)"
63 positive number, as long as this call succeeds, and then incrementing
64 \fIdest\fP by one and \fI*src\fP by the number of bytes consumed.
66 conversion can stop for three reasons:
68 An invalid multibyte sequence has been encountered.
69 In this case \fI*src\fP
70 is left pointing to the invalid multibyte sequence,
73 and \fIerrno\fP is set to \fBEILSEQ\fP.
75 The \fInms\fP limit forces a stop,
76 or \fIlen\fP non-L\(aq\\0\(aq wide characters
77 have been stored at \fIdest\fP.
78 In this case \fI*src\fP is left pointing to the
79 next multibyte sequence to be converted, and the number of wide characters
80 written to \fIdest\fP is returned.
82 The multibyte string has been completely converted, including the
83 terminating null wide character (\(aq\\0\(aq)
84 (which has the side effect of bringing back \fI*ps\fP to the
86 In this case \fI*src\fP is set to NULL, and the number of wide
87 characters written to \fIdest\fP,
88 excluding the terminating null wide character,
91 If \fIdest\fP is NULL, \fIlen\fP is ignored, and the conversion proceeds as
92 above, except that the converted wide characters
93 are not written out to memory,
94 and that no destination length limit exists.
96 In both of the above cases, if \fIps\fP is a NULL pointer, a static anonymous
97 state only known to the mbsnrtowcs function is used instead.
99 The programmer must ensure that there is room for at least \fIlen\fP wide
100 characters at \fIdest\fP.
104 function returns the number of wide characters
105 that make up the converted part of the wide-character string,
106 not including the terminating null wide character.
107 If an invalid multibyte sequence was
110 is returned, and \fIerrno\fP set to \fBEILSEQ\fP.
121 Passing NULL as \fIps\fP is not multithread safe.