1MBRLEN(3P) POSIX Programmer's Manual MBRLEN(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 mbrlen - get number of bytes in a character (restartable)
13
15 #include <wchar.h>
16
17 size_t mbrlen(const char *restrict s, size_t n,
18 mbstate_t *restrict ps);
19
20
22 If s is not a null pointer, mbrlen() shall determine the number of
23 bytes constituting the character pointed to by s. It shall be equiva‐
24 lent to:
25
26
27 mbstate_t internal;
28 mbrtowc(NULL, s, n, ps != NULL ? ps : &internal);
29
30 If ps is a null pointer, the mbrlen() function shall use its own inter‐
31 nal mbstate_t object, which is initialized at program start-up to the
32 initial conversion state. Otherwise, the mbstate_t object pointed to by
33 ps shall be used to completely describe the current conversion state of
34 the associated character sequence. The implementation shall behave as
35 if no function defined in this volume of IEEE Std 1003.1-2001 calls
36 mbrlen().
37
38 The behavior of this function is affected by the LC_CTYPE category of
39 the current locale.
40
42 The mbrlen() function shall return the first of the following that
43 applies:
44
45 0 If the next n or fewer bytes complete the character that corre‐
46 sponds to the null wide character.
47
48 positive
49 If the next n or fewer bytes complete a valid character; the
50 value returned shall be the number of bytes that complete the
51 character.
52
53 (size_t)-2
54 If the next n bytes contribute to an incomplete but potentially
55 valid character, and all n bytes have been processed. When n has
56 at least the value of the {MB_CUR_MAX} macro, this case can only
57 occur if s points at a sequence of redundant shift sequences
58 (for implementations with state-dependent encodings).
59
60 (size_t)-1
61 If an encoding error occurs, in which case the next n or fewer
62 bytes do not contribute to a complete and valid character. In
63 this case, [EILSEQ] shall be stored in errno and the conversion
64 state is undefined.
65
66
68 The mbrlen() function may fail if:
69
70 EINVAL ps points to an object that contains an invalid conversion
71 state.
72
73 EILSEQ Invalid character sequence is detected.
74
75
76 The following sections are informative.
77
79 None.
80
82 None.
83
85 None.
86
88 None.
89
91 mbsinit(), mbrtowc(), the Base Definitions volume of
92 IEEE Std 1003.1-2001, <wchar.h>
93
95 Portions of this text are reprinted and reproduced in electronic form
96 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
97 -- Portable Operating System Interface (POSIX), The Open Group Base
98 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
99 Electrical and Electronics Engineers, Inc and The Open Group. In the
100 event of any discrepancy between this version and the original IEEE and
101 The Open Group Standard, the original IEEE and The Open Group Standard
102 is the referee document. The original Standard can be obtained online
103 at http://www.opengroup.org/unix/online.html .
104
105
106
107IEEE/The Open Group 2003 MBRLEN(3P)