1 .\" $NetBSD: src/lib/libc/locale/mbsrtowcs.3,v 1.8 2004/01/24 16:58:54 wiz Exp $
2 .\" $DragonFly: src/lib/libc/locale/mbsrtowcs.3,v 1.1 2005/03/12 00:18:01 joerg Exp $
4 .\" Copyright (c)2002 Citrus Project,
5 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" ----------------------------------------------------------------------
34 .Nd converts a multibyte character string to a wide character string \
36 .\" ----------------------------------------------------------------------
39 .\" ----------------------------------------------------------------------
43 .Fn mbsrtowcs "wchar_t * restrict pwcs" "const char ** restrict s" "size_t n" \
44 "mbstate_t * restrict ps"
45 .\" ----------------------------------------------------------------------
49 converts the multibyte character string indirectly pointed to by
51 to the corresponding wide character string, and stores it in the
54 The conversion stops due to the following reasons:
57 The conversion reaches a null byte.
58 In this case, the null byte is also converted.
66 The conversion encounters an invalid character.
69 Each character will be converted as if
71 is continuously called.
79 the pointer object pointed to by
83 pointer (if the conversion is stopped due to reaching a null byte)
84 or the first byte of the character just after the last character converted.
90 pointer and the conversion is stopped due to reaching
93 places the state object pointed to by
95 to an initial state after the conversion has taken place.
101 category of the current locale.
103 These are the special cases:
104 .Bl -tag -width 012345678901
105 .It "s == NULL || *s == NULL"
106 Undefined (may cause the program to crash).
108 The conversion has taken place, but the resulting wide character string
110 In this case, the pointer object pointed to by
118 uses its own internal state object to keep the conversion state,
121 mentioned in this manual page.
123 Calling any other functions in
125 never changes the internal state of
127 which is initialized at startup time of the program.
129 .\" ----------------------------------------------------------------------
133 .Bl -tag -width 012345678901
135 The value returned is the number of elements stored in the array
138 except for a terminating null wide character (if any).
141 is not null and the value returned is equal to
143 the wide character string pointed to by
145 is not null terminated.
148 is a null pointer, the value returned is the number of elements to contain
149 the whole string converted, except for a terminating null wide character.
151 The array indirectly pointed to by
153 contains a byte sequence forming invalid character.
158 to indicate the error.
160 .\" ----------------------------------------------------------------------
163 may cause an error in the following case:
166 The pointer pointed to by
168 points to an invalid or incomplete multibyte character.
171 points to an invalid or uninitialized mbstate_t object.
173 .\" ----------------------------------------------------------------------
178 .\" ----------------------------------------------------------------------
184 The restrict qualifier is added at