1MBLEN(3P) POSIX Programmer's Manual MBLEN(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 mblen - get number of bytes in a character
13
15 #include <stdlib.h>
16
17 int mblen(const char *s, size_t n);
18
19
21 If s is not a null pointer, mblen() shall determine the number of bytes
22 constituting the character pointed to by s. Except that the shift state
23 of mbtowc() is not affected, it shall be equivalent to:
24
25
26 mbtowc((wchar_t *)0, s, n);
27
28 The implementation shall behave as if no function defined in this vol‐
29 ume of IEEE Std 1003.1-2001 calls mblen().
30
31 The behavior of this function is affected by the LC_CTYPE category of
32 the current locale. For a state-dependent encoding, this function shall
33 be placed into its initial state by a call for which its character
34 pointer argument, s, is a null pointer. Subsequent calls with s as
35 other than a null pointer shall cause the internal state of the func‐
36 tion to be altered as necessary. A call with s as a null pointer shall
37 cause this function to return a non-zero value if encodings have state
38 dependency, and 0 otherwise. If the implementation employs special
39 bytes to change the shift state, these bytes shall not produce separate
40 wide-character codes, but shall be grouped with an adjacent character.
41 Changing the LC_CTYPE category causes the shift state of this function
42 to be unspecified.
43
45 If s is a null pointer, mblen() shall return a non-zero or 0 value, if
46 character encodings, respectively, do or do not have state-dependent
47 encodings. If s is not a null pointer, mblen() shall either return 0
48 (if s points to the null byte), or return the number of bytes that con‐
49 stitute the character (if the next n or fewer bytes form a valid char‐
50 acter), or return -1 (if they do not form a valid character) and may
51 set errno to indicate the error. In no case shall the value returned
52 be greater than n or the value of the {MB_CUR_MAX} macro.
53
55 The mblen() function may fail if:
56
57 EILSEQ Invalid character sequence is detected.
58
59
60 The following sections are informative.
61
63 None.
64
66 None.
67
69 None.
70
72 None.
73
75 mbtowc(), mbstowcs(), wctomb(), wcstombs(), the Base Definitions volume
76 of IEEE Std 1003.1-2001, <stdlib.h>
77
79 Portions of this text are reprinted and reproduced in electronic form
80 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
81 -- Portable Operating System Interface (POSIX), The Open Group Base
82 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
83 Electrical and Electronics Engineers, Inc and The Open Group. In the
84 event of any discrepancy between this version and the original IEEE and
85 The Open Group Standard, the original IEEE and The Open Group Standard
86 is the referee document. The original Standard can be obtained online
87 at http://www.opengroup.org/unix/online.html .
88
89
90
91IEEE/The Open Group 2003 MBLEN(3P)