9330 stack overflow when creating a deeply nested dataset
[unleashed.git] / usr / src / man / man3c / wcrtomb.3c
blob9a3478cb07b46e15710347cbbd786b85d6ed27b7
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 WCRTOMB 3C "Jun 24, 2014"
48 .SH NAME
49 wcrtomb, wcrtomb_l \- convert a wide-character code to a character (restartable)
50 .SH SYNOPSIS
51 .LP
52 .nf
53 #include <stdio.h>
55 \fBsize_t\fR \fBwcrtomb\fR(\fBchar *restrict\fR \fIs\fR, \fBwchar_t\fR \fIwc\fR, \fBmbstate_t *restrict\fR \fIps\fR);
56 .fi
57 .LP
58 .nf
59 #include <stdio.h>
60 #include <xlocale.h>
62 \fBsize_t\fR \fBwcrtomb_l\fR(\fBchar *restrict\fR \fIs\fR, \fBwchar_t\fR \fIwc\fR, \fBmbstate_t *restrict\fR \fIps\fR,
63     \fBlocale_t\fR \fIloc\fR);
64 .fi
65 .SH DESCRIPTION
66 .LP
67 If \fIs\fR is a null pointer, the \fBwcrtomb()\fR function is equivalent to the
68 call:
69 .IP
70 \fBwcrtomb\fR(\fIbuf\fR, L'\e0', \fIps\fR);
71 .LP
72 where \fIbuf\fR is an internal buffer.
73 .LP
74 If \fIs\fR is not a null pointer, the \fBwcrtomb()\fR function determines the
75 number of bytes needed to represent the character that corresponds to the
76 wide-character given by \fIwc\fR (including any shift sequences), and stores
77 the resulting bytes in the array whose first element is pointed to by \fIs\fR.
78 At most \fBMB_CUR_MAX\fR bytes are stored.  If \fIwc\fR is a null
79 wide-character, a null byte is stored, preceded by any shift sequence needed to
80 restore the initial shift state. The resulting state described is the initial
81 conversion state.
82 .LP
83 If \fIps\fR is a null pointer, the \fBwcrtomb()\fR function uses its own
84 internal \fBmbstate_t\fR object, which is initialized at program startup to the
85 initial conversion state.   Otherwise, the  \fBmbstate_t\fR object pointed to
86 by \fIps\fR is used to completely describe the current conversion state of the
87 associated character sequence. The system will behave as if no function
88 defined in the Reference Manual calls \fBwcrtomb()\fR.
89 .LP
90 The behavior of \fBwcrtomb()\fR is affected by the \fBLC_CTYPE\fR category of the
91 current locale.  See \fBenviron\fR(5). The function \fBwcrtomb_l()\fR behaves
92 identically to \fBwcrtomb()\fR, except instead of operating in the current
93 locale, it operates in the locale specified by \fIloc\fR.
94 .SH RETURN VALUES
95 .LP
96 The \fBwcrtomb()\fR function returns the number of bytes stored in the array
97 object (including any shift sequences).  When \fIwc\fR is not a valid
98 wide-character, an encoding error occurs.  In this case, the function stores
99 the value of the macros \fBEILSEQ\fR in \fBerrno\fR and returns
100 \fB(size_t)\(mi1\fR; the conversion state is undefined.
101 .SH ERRORS
103 The \fBwcrtomb()\fR function may fail if:
105 .ne 2
107 \fB\fBEINVAL\fR\fR
109 .RS 10n
110 The \fIps\fR argument points to an object that contains an invalid conversion
111 state.
115 .ne 2
117 \fB\fBEILSEQ\fR\fR
119 .RS 10n
120 Invalid wide-character code is detected.
122 .SH ATTRIBUTES
124 See \fBattributes\fR(5) for descriptions of the following attributes:
126 box;
127 c | c
128 l | l .
129 ATTRIBUTE TYPE  ATTRIBUTE VALUE
131 Interface Stability     See below.
133 MT-Level        See below.
137 The \fBwcrtomb()\fR function is Standard.  The
138 \fBwcrtomb_l()\fR function is Uncommitted.
140 If \fIps\fR is a null pointer, these functions should be considered Unsafe
141 for use in multithreaded applications.  Otherwise, they are MT-Safe.
142 .SH SEE ALSO
144 \fBmbsinit\fR(3C), \fBnewlocale\fR(3C), \fBsetlocale\fR(3C),
145 \fBuselocale\fR(3C), \fBattributes\fR(5),
146 \fBstandards\fR(5), \fBenviron\fR(5)