summaryrefslogtreecommitdiffstats
path: root/man3p/mblen.3p
blob: 6f84afb44ce39b6296d4597d4eb9f17b23002eba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "MBLEN" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" mblen 
.SH NAME
mblen \- get number of bytes in a character
.SH SYNOPSIS
.LP
\fB#include <stdlib.h>
.br
.sp
int mblen(const char *\fP\fIs\fP\fB, size_t\fP \fIn\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
If \fIs\fP is not a null pointer, \fImblen\fP() shall determine the
number of bytes constituting the character pointed to by
\fIs\fP. Except that the shift state of \fImbtowc\fP() is not affected,
it shall be
equivalent to:
.sp
.RS
.nf

\fBmbtowc((wchar_t *)0,\fP \fIs\fP\fB,\fP \fIn\fP\fB);
\fP
.fi
.RE
.LP
The implementation shall behave as if no function defined in this
volume of IEEE\ Std\ 1003.1-2001 calls
\fImblen\fP().
.LP
The behavior of this function is affected by the \fILC_CTYPE\fP category
of the current locale. For a state-dependent encoding,
this function shall be placed into its initial state by a call for
which its character pointer argument, \fIs\fP, is a null
pointer. Subsequent calls with \fIs\fP as other than a null pointer
shall cause the internal state of the function to be altered
as necessary. A call with \fIs\fP as a null pointer shall cause this
function to return a non-zero value if encodings have state
dependency, and 0 otherwise. If the implementation employs special
bytes to change the shift state, these bytes shall not produce
separate wide-character codes, but shall be grouped with an adjacent
character. Changing the \fILC_CTYPE\fP category causes the
shift state of this function to be unspecified.
.SH RETURN VALUE
.LP
If \fIs\fP is a null pointer, \fImblen\fP() shall return a non-zero
or 0 value, if character encodings, respectively, do or do
not have state-dependent encodings. If \fIs\fP is not a null pointer,
\fImblen\fP() shall either return 0 (if \fIs\fP points to
the null byte), or return the number of bytes that constitute the
character (if the next \fIn\fP or fewer bytes form a valid
character), or return -1 (if they do not form a valid character) 
\ and may set \fIerrno\fP to indicate the error.  In no case shall
the value returned be greater than \fIn\fP or the value of
the {MB_CUR_MAX} macro.
.SH ERRORS
.LP
The \fImblen\fP() function may fail if:
.TP 7
.B EILSEQ
Invalid character sequence is detected. 
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fImbtowc\fP() , \fImbstowcs\fP() , \fIwctomb\fP() , \fIwcstombs\fP()
, the Base Definitions volume of
IEEE\ Std\ 1003.1-2001, \fI<stdlib.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .