9330 stack overflow when creating a deeply nested dataset
[unleashed.git] / usr / src / man / man3c / mbsrtowcs.3c
blobbf4d3a04d9ea6b8334b98469b317a7ba6746361e
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright (c) 1992, X/Open Company Limited. All Rights Reserved.
44 .\" Portions Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
45 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
46 .\"
47 .TH MBSRTOWCS 3C "Jun 28, 2014"
48 .SH NAME
49 mbsnrtowcs, mbsnrtowcs_l, mbsrtowcs, mbsrtowcs_l \- convert a character string
50 to a wide-character string (restartable)
51 .SH SYNOPSIS
52 .LP
53 .nf
54 #include <wchar.h>
56 \fBsize_t\fR \fBmbsnrtowcs\fR(\fBwchar_t *restrict\fR \fIdst\fR, \fBconst char **restrict\fR \fIsrc\fR,
57      \fBsize_t\fR \fInms\fR, \fBsize_t\fR \fIlen\fR, \fBmbstate_t *restrict\fR \fIps\fR);
58 .fi
59 .LP
60 .nf
61 \fBsize_t\fR \fBmbsrtowcs\fR(\fBwchar_t *restrict\fR \fIdst\fR, \fBconst char **restrict\fR \fIsrc\fR,
62      \fBsize_t\fR \fIlen\fR, \fBmbstate_t *restrict\fR \fIps\fR);
63 .fi
64 .LP
65 .nf
66 #include <wchar.h>
67 #include <xlocale.h>
69 \fBsize_t\fR \fBmbsnrtowcs_l\fR(\fBwchar_t *restrict\fR \fIdst\fR, \fBconst char **restrict\fR \fIsrc\fR,
70      \fBsize_t\fR \fInms\fR, \fBsize_t\fR \fIlen\fR, \fBmbstate_t *restrict\fR \fIps\fR, \fBlocale_t\fR \fIloc\fR);
71 .fi
72 .LP
73 .nf
74 \fBsize_t\fR \fBmbsrtowcs_l\fR(\fBwchar_t *restrict\fR \fIdst\fR, \fBconst char **restrict\fR \fIsrc\fR,
75      \fBsize_t\fR \fIlen\fR, \fBmbstate_t *restrict\fR \fIps\fR, \fBlocale_t\fR \fIloc\fR);
76 .fi
77 .SH DESCRIPTION
78 .LP
79 These function converts a sequence of characters, beginning in
80 the conversion state described by the object pointed to by \fIps\fR, from the
81 array indirectly pointed to by \fIsrc\fR into a sequence of corresponding
82 wide-characters. If \fIdst\fR is not a null pointer, the converted characters
83 are stored into the array pointed to by \fIdst\fR. Conversion continues up to
84 and including a terminating null character, which is also stored.  Conversion
85 stops early in either of the following cases:
86 .RS +4
87 .TP
88 .ie t \(bu
89 .el o
90 When a sequence of bytes is encountered that does not form a valid character.
91 .RE
92 .RS +4
93 .TP
94 .ie t \(bu
95 .el o
96 When \fIlen\fR codes have been stored into the array pointed to by \fIdst\fR
97 (and  \fIdst\fR is not a null pointer).
98 .RE
99 .LP
100 Each conversion takes place as if by a call to the \fBmbrtowc()\fR function.
102 If \fIdst\fR is not a null pointer, the pointer object pointed to by \fIsrc\fR
103 is assigned either a null pointer (if conversion stopped due to reaching a
104 terminating null character) or the address just past the last character
105 converted (if any).  If conversion stopped due to reaching a terminating null
106 character, and if \fIdst\fR is not a null pointer, the resulting state
107 described is the initial conversion state.
109 If \fIps\fR is a null pointer, these functions uses their own
110 internal \fBmbstate_t\fR object, which is initialized at program startup to the
111 initial conversion state.  Otherwise, the \fBmbstate_t\fR object pointed to by
112 \fIps\fR is used to completely describe the current conversion state of the
113 associated character sequence. The system will behave as if no function defined
114 in the Reference Manual calls any of these functions.
116 The function \fBmbsnrtowcs()\fR behaves identically to \fBmbsrtowcs()\fR,
117 except the conversion stops after reading \fInms\fR bytes from the
118 buffer pointed to by \fIsrc\fR.
120 The behavior of \fBmbnrtowcs()\fR and \fBmbsrtowcs()\fR functions are
121 affected by the \fBLC_CTYPE\fR category of the
122 current locale.  See \fBenviron\fR(5). The functions \fBmbsrtowcs_l()\fR and
123 \fBmbsnrtowcs_l()\fR behave identically to \fBmbsrtowcs()\fR and
124 \fBmbsnrtowcs()\fR, except that instead of using the current locale, they use
125 the locale specified by \fIloc\fR.
126 .SH RETURN VALUES
128 If the input conversion encounters a sequence of bytes that do not form a valid
129 character, an encoding error occurs.  In this case, these
130 functions store the value of the macro \fBEILSEQ\fR in \fBerrno\fR and return
131 \fB(size_t)\(mi1\fR; the conversion state is undefined.  Otherwise, they return
132 the number of characters successfully converted, not including the terminating
133 null (if any).
134 .SH ERRORS
136 Theses functions may fail if:
138 .ne 2
140 \fB\fBEINVAL\fR\fR
142 .RS 10n
143 The \fIps\fR argument points to an object that contains an invalid conversion
144 state.
148 .ne 2
150 \fB\fBEILSEQ\fR\fR
152 .RS 10n
153 Invalid character sequence is detected.
155 .SH ATTRIBUTES
157 See \fBattributes\fR(5) for descriptions of the following attributes:
159 box;
160 c | c
161 l | l .
162 ATTRIBUTE TYPE  ATTRIBUTE VALUE
164 Interface Stability     See below.
166 MT-Level        See below.
171 .B mbsnrtowcs()
173 .B mbsrtowcs()
174 functions are Standard.  The
175 .B mbsnrtowcs_l()
177 .B mbsrtowcs_l()
178 functions are Uncommitted.
180 If \fIps\fR is not a null pointer, these functions use the \fBmbstate_t\fR
181 object pointed to by \fIps\fR and can be used safely in
182 multithreaded applications, otherwise they use an
183 internal \fBmbstate_t\fR object and are Unsafe in multithreaded
184 applications.
185 .SH SEE ALSO
187 \fBmbrtowc\fR(3C), \fBmbsinit\fR(3C), \fBnewlocale\fR(3C),
188 \fBsetlocale\fR(3C), \fBuselocale()\fR, \fBattributes\fR(5),
189 \fBenviron\fR(5), \fBstandards\fR(5)