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) 2002, Sun Microsystems, Inc. All Rights Reserved.
45 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
47 .TH MBTOWC 3C "Jun 23, 2014"
49 mbtowc, mbtowc_l \- convert a character to a wide-character code
55 \fBint\fR \fBmbtowc\fR(\fBwchar_t *restrict\fR \fIpwc\fR, \fBconst char *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR);
62 \fBint\fR \fBmbtowc_l\fR(\fBwchar_t *restrict\fR \fIpwc\fR, \fBconst char *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR,
63 \fBlocale_t\fR \fIloc\fR);
67 If \fIs\fR is not a null pointer, \fBmbtowc()\fR determines the number of the
68 bytes that constitute the character pointed to by \fIs\fR. It then determines
69 the wide-character code for the value of type \fBwchar_t\fR that corresponds to
70 that character. (The value of the wide-character code corresponding to the null
71 byte is 0.) If the character is valid and \fIpwc\fR is not a null pointer,
72 \fBmbtowc()\fR stores the wide-character code in the object pointed to by
75 A call with \fIs\fR as a null pointer causes this function to return \fB0\fR.
76 The behavior of this function is affected by the \fBLC_CTYPE\fR category of the
77 current locale. At most \fIn\fR bytes of the array pointed to by \fIs\fR will
80 The function \fBmbtowc_l()\fR behaves identically to \fBmbtowc()\fR, except
81 instead of using the current locale, it uses the locale as specified by
85 If \fIs\fR is a null pointer, these functions return \fB0\fR. If \fIs\fR is not
86 a null pointer, they return \fB0\fR (if \fIs\fR points to the null
87 byte), the number of bytes that constitute the converted character (if the next
88 \fIn\fR or fewer bytes form a valid character), or \fB\(mi1\fR and may set
89 \fBerrno\fR to indicate the error (if they do not form a valid character).
91 In no case will the value returned be greater than \fIn\fR or the value of the
92 \fBMB_CUR_MAX\fR macro.
95 The \fBmbtowc()\fR and \fBmbtowc_l()\fR functions may fail if:
102 Invalid character sequence is detected.
106 See \fBattributes\fR(5) for descriptions of the following attributes:
111 ATTRIBUTE TYPE ATTRIBUTE VALUE
115 Interface Stability See below.
123 function is Standard. The
125 function is Uncommitted.
128 \fBmblen\fR(3C), \fBmbstowcs\fR(3C),
129 \fBnewlocale\fR(3C), \fBsetlocale\fR(3C), \fBuselocale\fR(3C),
130 \fBwcstombs\fR(3C), \fBwctomb\fR(3C), \fBattributes\fR(5), \fBstandards\fR(5)