2 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
6 .\" References consulted:
7 .\" GNU glibc-2 source code and manual
8 .\" Dinkumware C library reference http://www.dinkumware.com/
9 .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
12 .TH mbsrtowcs 3 (date) "Linux man-pages (unreleased)"
14 mbsrtowcs \- convert a multibyte string to a wide-character string (restartable)
17 .RI ( libc ", " \-lc )
22 .BI "size_t mbsrtowcs(wchar_t " dest "[restrict ." dsize ],
23 .BI " const char **restrict " src ,
24 .BI " size_t " dsize ", mbstate_t *restrict " ps );
33 to a wide-character string starting at
37 wide characters are written to
42 The conversion is effectively performed by repeatedly
44 .I "mbrtowc(dest, *src, n, ps)"
48 positive number, as long as this call succeeds, and then incrementing
52 by the number of bytes consumed.
53 The conversion can stop for three reasons:
55 An invalid multibyte sequence has been encountered.
58 is left pointing to the invalid multibyte sequence,
67 non-L\[aq]\e0\[aq] wide characters have been stored at
71 is left pointing to the next
72 multibyte sequence to be converted,
73 and the number of wide characters written to
77 The multibyte string has been completely converted, including the
78 terminating null wide character (\[aq]\e0\[aq]), which has the side
79 effect of bringing back
85 is set to NULL, and the number of wide
88 excluding the terminating null wide character, is returned.
95 and the conversion proceeds as above,
96 except that the converted wide characters are not written out to memory,
97 and that no length limit exists.
99 In both of the above cases,
102 is NULL, a static anonymous
103 state known only to the
105 function is used instead.
107 In order to avoid the case 2 above, the programmer should make sure
110 greater than or equal to
111 .IR "mbsrtowcs(NULL,src,0,ps)+1" .
113 The programmer must ensure that there is room for at least
119 This function is a restartable version of
122 The number of wide characters that make
123 up the converted part of the wide-character string, not including the
124 terminating null wide character.
125 If an invalid multibyte sequence was
133 For an explanation of the terms used in this section, see
139 Interface Attribute Value
147 MT-Unsafe race:mbsrtowcs/!ps
164 is not multithread safe.