1 .\" $NetBSD: src/lib/libc/locale/wcsrtombs.3,v 1.8 2004/01/24 16:58:54 wiz Exp $
2 .\" $DragonFly: src/lib/libc/locale/wcsrtombs.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 wide character string to a multibyte character string \
36 .\" ----------------------------------------------------------------------
39 .\" ----------------------------------------------------------------------
43 .Fn wcsrtombs "const char * restrict s" "const wchar_t ** restrict pwcs" \
44 "size_t n" "mbstate_t * restrict ps"
45 .\" ----------------------------------------------------------------------
49 converts the null-terminated wide character string indirectly pointed
52 to the corresponding multibyte character string,
53 and stores it in the array pointed to by
55 The conversion stops due to the following reasons:
58 The conversion reaches a null wide character.
59 In this case, the null wide character is also converted.
65 bytes in the array pointed to by
68 The conversion encounters an invalid character.
71 Each character will be converted as if
73 is continuously called, except the internal state of
82 pointer, the pointer object pointed to by
86 pointer (if the conversion is stopped due to reaching a null wide character)
87 or the first byte of the character just after the last character converted.
93 pointer and the conversion is stopped due to reaching
94 a null wide character,
96 places the state object pointed to by
98 to an initial state after the conversion is taken place.
104 category of the current locale.
106 These are the special cases:
107 .Bl -tag -width 012345678901
110 returns the number of bytes to store the whole multibyte character string
111 corresponding to the wide character string pointed to by
113 not including the terminating null byte.
117 .It "pwcs == NULL || *pwcs == NULL"
118 Undefined (may cause the program to crash).
121 uses its own internal state object to keep the conversion state,
124 mentioned in this manual page.
126 Calling any other functions in
128 never changes the internal
131 which is initialized at startup time of the program.
133 .\" ----------------------------------------------------------------------
137 .Bl -tag -width 012345678901
139 Number of bytes stored in the array pointed to by
141 except for a null byte.
142 There are no cases that the value returned is greater than
147 If the return value is equal to
149 the string pointed to by
151 will not be null-terminated.
154 points to a string containing an invalid wide character.
159 to indicate the error.
161 .\" ----------------------------------------------------------------------
164 may cause an error in the following case:
168 points to a string containing an invalid wide character.
170 .\" ----------------------------------------------------------------------
175 .\" ----------------------------------------------------------------------
181 The restrict qualifier is added at