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