1 .\" $NetBSD: mbsrtowcs.3,v 1.10 2006/10/16 08:42:16 wiz Exp $
3 .\" Copyright (c)2002 Citrus Project,
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" ----------------------------------------------------------------------
33 .Nd converts a multibyte character string to a wide character string \
35 .\" ----------------------------------------------------------------------
38 .\" ----------------------------------------------------------------------
42 .Fn mbsrtowcs "wchar_t * restrict pwcs" "const char ** restrict s" "size_t n" \
43 "mbstate_t * restrict ps"
44 .\" ----------------------------------------------------------------------
48 converts the multibyte character string indirectly pointed to by
50 to the corresponding wide character string, and stores it in the
53 The conversion stops due to the following reasons:
56 The conversion reaches a nul byte.
57 In this case, the nul byte is also converted.
65 The conversion encounters an invalid character.
68 Each character will be converted as if
70 is continuously called.
75 is not a null pointer,
76 the pointer object pointed to by
78 is a null pointer (if the conversion is stopped due to reaching a
79 nul byte) or the first byte of the character just after the last
84 is not a null pointer and the conversion is stopped due to reaching
87 places the state object pointed to by
89 to an initial state after the conversion has taken place.
95 category of the current locale.
97 These are the special cases:
98 .Bl -tag -width 012345678901
99 .It "s == NULL || *s == NULL"
100 Undefined (may cause the program to crash).
102 The conversion has taken place, but the resulting wide character string
104 In this case, the pointer object pointed to by
112 uses its own internal state object to keep the conversion state,
115 mentioned in this manual page.
117 Calling any other functions in
119 never changes the internal state of
121 which is initialized at startup time of the program.
123 .\" ----------------------------------------------------------------------
127 .Bl -tag -width 012345678901
129 The value returned is the number of elements stored in the array
132 except for a terminating nul wide character (if any).
137 and the value returned is equal to
139 the wide character string pointed to by
141 is not nul-terminated.
144 is a null pointer, the value returned is the number of elements to contain
145 the whole string converted, except for a terminating nul wide character.
147 The array indirectly pointed to by
149 contains a byte sequence forming invalid character.
154 to indicate the error.
156 .\" ----------------------------------------------------------------------
159 may cause an error in the following case:
162 The pointer pointed to by
164 points to an invalid or incomplete multibyte character.
167 points to an invalid or uninitialized mbstate_t object.
169 .\" ----------------------------------------------------------------------
174 .\" ----------------------------------------------------------------------
180 The restrict qualifier is added at