1MBLEN(3) Linux Programmer's Manual MBLEN(3)
2
3
4
6 mblen - determine number of bytes in next multibyte character
7
9 #include <stdlib.h>
10
11 int mblen(const char *s, size_t n);
12
14 If s is not a NULL pointer, the mblen() function inspects at most n
15 bytes of the multibyte string starting at s and extracts the next com‐
16 plete multibyte character. It uses a static anonymous shift state only
17 known to the mblen function. If the multibyte character is not the null
18 wide character, it returns the number of bytes that were consumed from
19 s. If the multibyte character is the null wide character, it returns 0.
20
21 If the n bytes starting at s do not contain a complete multibyte char‐
22 acter, mblen() returns -1. This can happen even if n >= MB_CUR_MAX, if
23 the multibyte string contains redundant shift sequences.
24
25 If the multibyte string starting at s contains an invalid multibyte
26 sequence before the next complete character, mblen() also returns -1.
27
28 If s is a NULL pointer, the mblen() function resets the shift state,
29 only known to this function, to the initial state, and returns non-zero
30 if the encoding has non-trivial shift state, or zero if the encoding is
31 stateless.
32
34 The mblen() function returns the number of bytes parsed from the multi‐
35 byte sequence starting at s, if a non-null wide character was recog‐
36 nized. It returns 0, if a null wide character was recognized. It
37 returns -1, if an invalid multibyte sequence was encountered or if it
38 couldn't parse a complete multibyte character.
39
41 C99
42
44 mbrlen(3)
45
47 The behaviour of mblen() depends on the LC_CTYPE category of the cur‐
48 rent locale.
49
50 The function mbrlen() provides a better interface to the same function‐
51 ality.
52
53
54
55GNU 1999-07-25 MBLEN(3)