1 .\" $NetBSD: wcsrtombs.3,v 1.13 2010/12/16 17:42:27 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 wide-character string to a multibyte character string \
35 .\" ----------------------------------------------------------------------
38 .\" ----------------------------------------------------------------------
42 .Fn wcsrtombs "char * restrict s" "const wchar_t ** restrict pwcs" \
43 "size_t n" "mbstate_t * restrict ps"
44 .\" ----------------------------------------------------------------------
48 converts the nul-terminated wide-character string indirectly pointed
51 to the corresponding multibyte character string,
52 and stores it in the array pointed to by
54 The conversion stops due to the following reasons:
57 The conversion reaches a nul wide character.
58 In this case, the nul wide character is also converted.
64 bytes in the array pointed to by
67 The conversion encounters an invalid character.
70 Each character will be converted as if
72 is continuously called, except the internal state of
79 is not a null pointer, the pointer object pointed to by
81 is a null pointer (if the conversion is stopped due to reaching a
82 nul wide character) or the first byte of the character just after
83 the last character converted.
87 is not a null pointer and the conversion is stopped due to reaching
90 places the state object pointed to by
92 to an initial state after the conversion is taken place.
98 category of the current locale.
100 These are the special cases:
101 .Bl -tag -width 012345678901
104 returns the number of bytes to store the whole multibyte character string
105 corresponding to the wide-character string pointed to by
107 not including the terminating nul byte.
111 .It "pwcs == NULL || *pwcs == NULL"
112 Undefined (may cause the program to crash).
115 uses its own internal state object to keep the conversion state,
118 mentioned in this manual page.
120 Calling any other functions in
122 never changes the internal
125 which is initialized at startup time of the program.
127 .\" ----------------------------------------------------------------------
131 .Bl -tag -width 012345678901
133 Number of bytes stored in the array pointed to by
135 except for a nul byte.
136 There are no cases that the value returned is greater than
141 If the return value is equal to
143 the string pointed to by
145 will not be nul-terminated.
148 points to a string containing an invalid wide character.
153 to indicate the error.
155 .\" ----------------------------------------------------------------------
158 may cause an error in the following case:
162 points to a string containing an invalid wide character.
164 .\" ----------------------------------------------------------------------
169 .\" ----------------------------------------------------------------------
175 The restrict qualifier is added at