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/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
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.
25 .\" This notice shall appear on any product containing this material.
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.
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.
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]
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>
47 .TH MBRTOWC 3C "Jun 23, 2014"
49 mbrtowc, mbrtowc_l \- convert a character to a wide-character code (restartable)
55 \fBsize_t\fR \fBmbrtowc\fR(\fBwchar_t *restrict\fR \fIpwc\fR, \fBconst char *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR,
56 \fBmbstate_t *restrict\fR \fIps\fR);
63 \fBsize_t\fR \fBmbrtowc_l\fR(\fBwchar_t *restrict\fR \fIpwc\fR, \fBconst char *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR,
64 \fBmbstate_t *restrict\fR \fIps\fR, \fBlocale_t\fR \fIloc\fR);
70 is a null pointer, the
72 function is equivalent to the call:
76 \fBmbrtowc\fR(NULL, "", 1, \fIps\fR)
82 is a null pointer, the
84 function is equivalent to the call:
88 \fBmbrtowc_l\fR(NULL, "", 1, \fIps\fR, \fIloc\fR);
92 In these cases, the values of the arguments
100 is not a null pointer, these functions inspect at most
102 bytes beginning at the byte pointed to by
104 to determine the number of bytes needed to complete the next character
105 (including any shift sequences). If the functions determine that the next
106 character is completed,
107 they determine the value of the corresponding wide-character and then, if
109 is not a null pointer, stores that value in the object pointed to by
111 If the corresponding wide-character is the null wide-character, the
112 resulting state described is the initial conversion state.
116 is a null pointer, these functions use their own
119 object, which is initialized at program startup to the
120 initial conversion state. Otherwise, the
124 is used to completely describe the current conversion state of the
125 associated character sequence. The system will behave as if no function defined
126 in the Reference Manual calls
135 category of the current locale. The
137 function is affected by the
139 category of the specified
149 functions return the first of the following that applies:
153 or fewer bytes complete the character that corresponds to
154 the null wide-character (which is the value stored).
158 or fewer bytes complete a valid character (which is the
159 value stored); the value returned is the number of bytes that complete the
161 .IP \fB(size_t)\(mi2\fR
164 bytes contribute to an incomplete but potentially valid
167 bytes have been processed (no value is stored).
170 has at least the value of the
172 macro, this case can only occur if
174 points at a sequence of redundant shift sequences
175 (for implementations with state-dependent encodings).
176 .IP \fB(size_t)\(mi1\fR
177 If an encoding error occurs, in which case the next \fIn\fR or fewer bytes do
178 not contribute to a complete and valid character (no value is stored). In
183 and the conversion state is undefined.
190 functions may fail if:
194 argument points to an object that contains an invalid conversion
197 Invalid character sequence is detected.
200 See \fBattributes\fR(5) for descriptions of the following attributes:
205 ATTRIBUTE TYPE ATTRIBUTE VALUE
207 Interface Stability See below.
215 function is Standard. The
217 function is Uncommitted.
221 is a null pointer, these functions are Unsafe for use in
222 multithreaded applications. Otherwise they are MT-Safe.