Unleashed v1.4
[unleashed.git] / share / man / man3c / mblen.3c
blobc482a5d1b51f6c22e6e6e0addb237416138f97b6
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 1989 AT&T
44 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
45 .\" Portions Copyright (c) 2002, Sun Microsystems, Inc.  All Rights Reserved
46 .\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
47 .\"
48 .TH MBLEN 3C "Jun 24, 2014"
49 .SH NAME
50 mblen, mblen_l \- get number of bytes in a character
51 .SH SYNOPSIS
52 .LP
53 .nf
54 #include <stdlib.h>
56 \fBint\fR \fBmblen\fR(\fBconst char *\fR\fIs\fR, \fBsize_t\fR \fIn\fR);
57 .fi
58 .LP
59 .nf
60 #include <stdlib.h>
61 #include <xlocale.h>
63 \fBint\fR \fBmblen_l\fR(\fBconst char *\fR\fIs\fR, \fBsize_t\fR \fIn\fR, \fBlocale_t\fR \fIloc\fR);
64 .fi
66 .SH DESCRIPTION
67 .sp
68 .LP
69 If \fIs\fR is not a null pointer, \fBmblen()\fR and \fBmblen_l()\fR
70 determine the number of bytes constituting the character pointed to by
71 \fIs\fR. The call
72 .IP
73 \fBmblen\fR(\fIs\fR, \fIn\fR);
74 .LP
75 is equivalent to:
76 .IP
77 \fBmbtowc\fR((\fBwchar_t\fR *)0, \fIs\fR, \fIn\fR);
78 .LP
79 A call with \fIs\fR as a null pointer causes this function to return \fB0\fR.
80 .LP
81 Whereas the behavior of the \fBmblen()\fR function is affected by the
82 \fBLC_CTYPE\fR category of the current locale, the behavior of
83 \fBmblen_l()\fR is affected by the \fBLC_CTYPE\fR category of the
84 locale specified by \fIloc\fR.
85 .SH RETURN VALUES
86 .LP
87 If \fIs\fR is a null pointer, \fBmblen()\fR and \fBmblen_l()\fR returns \fB0\fR. It \fIs\fR is not
88 a null pointer, \fBmblen()\fR and \fBmblen_l()\fR returns \fB0\fR (if \fIs\fR points to the null
89 byte), the number of bytes that constitute the character (if the next \fIn\fR
90 or fewer bytes form a valid character), or  \fB\(mi1\fR (if they do not form a
91 valid character) and may set \fBerrno\fR to indicate the error. In no case will
92 the value returned be greater than \fIn\fR or the value of the \fBMB_CUR_MAX\fR
93 macro.
94 .SH ERRORS
95 .sp
96 .LP
97 The \fBmblen()\fR and \fBmblen_l()\fR functions may fail if:
98 .sp
99 .ne 2
101 \fB\fBEILSEQ\fR\fR
103 .RS 10n
104 Invalid character sequence is detected.
106 .SH ATTRIBUTES
109 See \fBattributes\fR(5) for descriptions of the following attributes:
114 box;
115 c | c
116 l | l .
117 ATTRIBUTE TYPE  ATTRIBUTE VALUE
119 CSI     Enabled
121 Interface Stability     See below.
123 MT-Level        MT-Safe
128 .B mblen()
129 function is Standard. The
130 .B mblen_l()
131 function is Uncommitted.
132 .SH SEE ALSO
134 \fBmbstowcs\fR(3C), \fBmbtowc\fR(3C), \fBnewlocale\fR(3C), \fBsetlocale\fR(3C),
135 \fBwcstombs\fR(3C), \fBwctomb\fR(3C), \fBuselocale\fR(3C) \fBattributes\fR(5),
136 \fBstandards\fR(5)