]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/locale/wcsrtombs.3
libc: Purge unneeded cdefs.h
[FreeBSD/FreeBSD.git] / lib / libc / locale / wcsrtombs.3
1 .\" Copyright (c) 2002-2004 Tim J. Robbins
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .Dd July 21, 2004
26 .Dt WCSRTOMBS 3
27 .Os
28 .Sh NAME
29 .Nm wcsrtombs ,
30 .Nm wcsnrtombs
31 .Nd "convert a wide-character string to a character string (restartable)"
32 .Sh LIBRARY
33 .Lb libc
34 .Sh SYNOPSIS
35 .In wchar.h
36 .Ft size_t
37 .Fo wcsrtombs
38 .Fa "char * restrict dst" "const wchar_t ** restrict src"
39 .Fa "size_t len" "mbstate_t * restrict ps"
40 .Fc
41 .Ft size_t
42 .Fo wcsnrtombs
43 .Fa "char * restrict dst" "const wchar_t ** restrict src" "size_t nwc"
44 .Fa "size_t len" "mbstate_t * restrict ps"
45 .Fc
46 .Sh DESCRIPTION
47 The
48 .Fn wcsrtombs
49 function converts a string of wide characters indirectly pointed to by
50 .Fa src
51 to a corresponding multibyte character string stored in the array
52 pointed to by
53 .Fa dst .
54 No more than
55 .Fa len
56 bytes are written to
57 .Fa dst .
58 .Pp
59 If
60 .Fa dst
61 is
62 .Dv NULL ,
63 no characters are stored.
64 .Pp
65 If
66 .Fa dst
67 is not
68 .Dv NULL ,
69 the pointer pointed to by
70 .Fa src
71 is updated to point to the character after the one that conversion stopped at.
72 If conversion stops because a null character is encountered,
73 .Fa *src
74 is set to
75 .Dv NULL .
76 .Pp
77 The
78 .Vt mbstate_t
79 argument,
80 .Fa ps ,
81 is used to keep track of the shift state.
82 If it is
83 .Dv NULL ,
84 .Fn wcsrtombs
85 uses an internal, static
86 .Vt mbstate_t
87 object, which is initialized to the initial conversion state
88 at program startup.
89 .Pp
90 The
91 .Fn wcsnrtombs
92 function behaves identically to
93 .Fn wcsrtombs ,
94 except that conversion stops after reading at most
95 .Fa nwc
96 characters from the buffer pointed to by
97 .Fa src .
98 .Sh RETURN VALUES
99 The
100 .Fn wcsrtombs
101 and
102 .Fn wcsnrtombs
103 functions return the number of bytes stored in
104 the array pointed to by
105 .Fa dst
106 (not including any terminating null), if successful, otherwise it returns
107 .Po Vt size_t Pc Ns \-1 .
108 .Sh ERRORS
109 The
110 .Fn wcsrtombs
111 and
112 .Fn wcsnrtombs
113 functions will fail if:
114 .Bl -tag -width Er
115 .It Bq Er EILSEQ
116 An invalid wide character was encountered.
117 .It Bq Er EINVAL
118 The conversion state is invalid.
119 .El
120 .Sh SEE ALSO
121 .Xr mbsrtowcs 3 ,
122 .Xr wcrtomb 3 ,
123 .Xr wcstombs 3
124 .Sh STANDARDS
125 The
126 .Fn wcsrtombs
127 function conforms to
128 .St -isoC-99 .
129 .Pp
130 The
131 .Fn wcsnrtombs
132 function is an extension to the standard.