1mblen(3C) Standard C Library Functions mblen(3C)
2
3
4
6 mblen - get number of bytes in a character
7
9 #include <stdlib.h>
10
11 int mblen(const char *s, size_t n);
12
13
15 If s is not a null pointer, mblen() determines the number of bytes con‐
16 stituting the character pointed to by s. It is equivalent to:
17
18
19 mbtowc((wchar_t *)0, s, n);
20
21
22 A call with s as a null pointer causes this function to return 0. The
23 behavior of this function is affected by the LC_CTYPE category of the
24 current locale.
25
27 If s is a null pointer, mblen() returns 0. It s is not a null pointer,
28 mblen() returns 0 (if s points to the null byte), the number of bytes
29 that constitute the character (if the next n or fewer bytes form a
30 valid character), or −1 (if they do not form a valid character) and
31 may set errno to indicate the error. In no case will the value returned
32 be greater than n or the value of the MB_CUR_MAX macro.
33
35 The mblen() function may fail if:
36
37 EILSEQ Invalid character sequence is detected.
38
39
41 The mblen() function can be used safely in multithreaded applications,
42 as long as setlocale(3C) is not being called to change the locale.
43
45 See attributes(5) for descriptions of the following attributes:
46
47
48
49
50 ┌─────────────────────────────┬─────────────────────────────┐
51 │ATTRIBUTE TYPE │ATTRIBUTE VALUE │
52 ├─────────────────────────────┼─────────────────────────────┤
53 │CSI │Enabled │
54 ├─────────────────────────────┼─────────────────────────────┤
55 │Interface Stability │Standard │
56 ├─────────────────────────────┼─────────────────────────────┤
57 │MT-Level │MT-Safe with exceptions │
58 └─────────────────────────────┴─────────────────────────────┘
59
61 mbstowcs(3C), mbtowc(3C), setlocale(3C), wcstombs(3C), wctomb(3C),
62 attributes(5), standards(5)
63
64
65
66SunOS 5.11 24 Jul 2002 mblen(3C)