9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3c / wcsrtombs.3c
blobd07600309d2f377587721dc81681e4f836d764ec
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 WCSRTOMBS 3C "Jul 13, 2014"
48 .SH NAME
49 wcsnrtombs, wcsnrtombs_l, wcsrtombs, wcsrtombs_l \- convert a wide-character string to a character string
50 (restartable)
51 .SH SYNOPSIS
52 .LP
53 .nf
54 #include <wchar.h>
56 \fBsize_t\fR \fBwcsrtombs\fR(\fBchar *restrict\fR \fIdst\fR, \fBconst wchar_t **restrict\fR \fIsrc\fR,
57      \fBsize_t\fR \fIlen\fR, \fBmbstate_t *restrict\fR \fIps\fR);
58 .fi
59 .LP
60 .nf
61 \fBsize_t\fR \fBwcsnrtombs\fR(\fBchar *restrict\fR \fIdst\fR, \fBconst wchar_t **restrict\fR \fIsrc\fR,
62      \fBsize_t\fR \fInwc\fR, \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 \fBwcsrtombs_l\fR(\fBchar *restrict\fR \fIdst\fR, \fBconst wchar_t **restrict\fR \fIsrc\fR,
70      \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 \fBwcsnrtombs_l\fR(\fBchar *restrict\fR \fIdst\fR, \fBconst wchar_t **restrict\fR \fIsrc\fR,
75      \fBsize_t\fR \fInwc\fR, \fBsize_t\fR \fIlen\fR, \fBmbstate_t *restrict\fR \fIps\fR, \fBlocale_t\fR \fIloc\fR);
76 .fi
77 .SH DESCRIPTION
78 .LP
79 The \fBwcsrtombs()\fR function converts a sequence of wide-characters from the
80 array indirectly pointed to by \fIsrc\fR into a sequence of corresponding
81 characters, beginning in the conversion state described by the object pointed
82 to by \fIps\fR. If \fIdst\fR is not a null pointer, the converted characters
83 are then stored into the array pointed to by \fIdst\fR. Conversion continues up
84 to and including a terminating null  wide-character, which is also stored.
85 Conversion stops earlier in the following cases:
86 .RS +4
87 .TP
88 .ie t \(bu
89 .el o
90 When a code is reached that does not correspond to a valid character.
91 .RE
92 .RS +4
93 .TP
94 .ie t \(bu
95 .el o
96 When the next character would exceed the limit of \fIlen\fR total bytes to be
97 stored in the array pointed to by \fIdst\fR (and \fIdst\fR is not a null
98 pointer).
99 .RE
100 .RS +4
102 .ie t \(bu
103 .el o
104 In the case of \fBwcsnrtombs()\fR and \fBwcsnrtombs_l()\fR, when \fInwc\fR
105 wide characters have been completely converted.
108 Each conversion takes place as if by a call to the \fBwcrtomb()\fR function.
110 If \fIdst\fR is not a null pointer, the pointer object pointed to by \fIsrc\fR
111 is assigned either a null pointer (if conversion stopped due to reaching a
112 terminating null wide-character) or the address just  past the last
113 wide-character converted (if any). If conversion stopped due to reaching a
114 terminating null wide-character, the resulting state described is the initial
115 conversion state.
117 If \fIps\fR is a null pointer, these functions uses their own
118 internal \fBmbstate_t\fR object, which is initialized at program startup to the
119 initial conversion state.  Otherwise, the  \fBmbstate_t\fR object pointed to by
120 \fIps\fR is used to completely describe the current conversion state of the
121 associated character sequence. The system will behave as if no function defined
122 in the Reference Manual calls any of these functions.
124 The behavior of \fBwcsrtombs()\fR and \fBwcsnrtombs()\fR are affected by the
125 \fBLC_CTYPE\fR category of the current locale.  See \fBenviron\fR(5).
127 The \fBwcsrtombs_l()\fR and \fBwcsnrtombs_l()\fR functions behave identically
128 to \fBwcsrtombs()\fR and \fBwcsnrtombs()\fR respectively, except
129 that instead of operating in the current locale, they operate in the locale
130 specified by \fIloc\fR.
131 .SH RETURN VALUES
133 If conversion stops because a code is reached that does not correspond to a
134 valid character, an encoding error occurs.  In this case, these
135 functions store the value of the macro \fBEILSEQ\fR in \fBerrno\fR and return
136 \fB(size_t)\(mi1\fR; the conversion state is undefined.  Otherwise, they return
137 the number of bytes in the resulting character sequence, not including the
138 terminating null (if any).
139 .SH ERRORS
141 These functions may fail if:
143 .ne 2
145 \fB\fBEINVAL\fR\fR
147 .RS 10n
148 The \fIps\fR argument points to an object that contains an invalid conversion
149 state.
153 .ne 2
155 \fB\fBEILSEQ\fR\fR
157 .RS 10n
158 A wide-character code does not correspond to a valid character.
160 .SH ATTRIBUTES
162 See \fBattributes\fR(5) for descriptions of the following attributes:
164 box;
165 c | c
166 l | l .
167 ATTRIBUTE TYPE  ATTRIBUTE VALUE
169 Interface Stability     See below.
171 MT-Level        See below.
175 The \fBwcsrtombs()\fR and \fBwcsnrtombs()\fR functions are Standard.  The
176 \fBwcsrtombs_l()\fR and \fBwcsnrtombs_l()\fR functions are Uncommitted.
178 If \fIps\fR is a null pointer, these functions should be considered Unsafe
179 for use in multithreaded applications.  Otherwise, they are MT-Safe.
180 .SH SEE ALSO
182 \fBmbsinit\fR(3C), \fBnewlocale\fR(3C), \fBsetlocale\fR(3C), \fBuselocale\fR(3C),
183 \fBwcrtomb\fR(3C), \fBattributes\fR(5),
184 \fBenviron\fR(5), \fBstandards\fR(5)