9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3c / mbtowc.3c
blob9935a3596b66de5c7ba4cf2a0925aa97120107ec
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) 2002, Sun Microsystems, Inc.  All Rights Reserved.
45 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
46 .\"
47 .TH MBTOWC 3C "Jun 23, 2014"
48 .SH NAME
49 mbtowc, mbtowc_l \- convert a character to a wide-character code
50 .SH SYNOPSIS
51 .LP
52 .nf
53 #include <stdlib.h>
55 \fBint\fR \fBmbtowc\fR(\fBwchar_t *restrict\fR \fIpwc\fR, \fBconst char *restrict\fR \fIs\fR, \fBsize_t\fR \fIn\fR);
56 .fi
57 .LP
58 .nf
59 #include <stdlib.h>
60 #include <xlocale.h>
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);
64 .fi
65 .SH DESCRIPTION
66 .LP
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
73 \fIpwc\fR.
74 .LP
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
78 be examined.
79 .LP
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
82 \fIloc\fR.
83 .SH RETURN VALUES
84 .LP
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).
90 .LP
91 In no case will the value returned be greater than \fIn\fR or the value of the
92 \fBMB_CUR_MAX\fR macro.
93 .SH ERRORS
94 .LP
95 The \fBmbtowc()\fR and \fBmbtowc_l()\fR functions may fail if:
96 .sp
97 .ne 2
98 .na
99 \fB\fBEILSEQ\fR\fR
101 .RS 10n
102 Invalid character sequence is detected.
104 .SH ATTRIBUTES
106 See \fBattributes\fR(5) for descriptions of the following attributes:
108 box;
109 c | c
110 l | l .
111 ATTRIBUTE TYPE  ATTRIBUTE VALUE
113 CSI     Enabled
115 Interface Stability     See below.
117 MT-Level        MT-Safe
122 .B mbtowc()
123 function is Standard.  The
124 .B mbtowc_l()
125 function is Uncommitted.
126 .SH SEE ALSO
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)