1MBRLEN(3) Linux Programmer's Manual MBRLEN(3)
2
3
4
6 mbrlen - determine number of bytes in next multibyte character
7
9 #include <wchar.h>
10
11 size_t mbrlen(const char *restrict s, size_t n,
12 mbstate_t *restrict ps);
13
15 The mbrlen() function inspects at most n bytes of the multibyte string
16 starting at s and extracts the next complete multibyte character. It
17 updates the shift state *ps. If the multibyte character is not the
18 null wide character, it returns the number of bytes that were consumed
19 from s. If the multibyte character is the null wide character, it re‐
20 sets the shift state *ps to the initial state and returns 0.
21
22 If the n bytes starting at s do not contain a complete multibyte char‐
23 acter, mbrlen() returns (size_t) -2. This can happen even if n >=
24 MB_CUR_MAX, if the multibyte string contains redundant shift sequences.
25
26 If the multibyte string starting at s contains an invalid multibyte se‐
27 quence before the next complete character, mbrlen() returns (size_t) -1
28 and sets errno to EILSEQ. In this case, the effects on *ps are unde‐
29 fined.
30
31 If ps is NULL, a static anonymous state known only to the mbrlen()
32 function is used instead.
33
35 The mbrlen() function returns the number of bytes parsed from the
36 multibyte sequence starting at s, if a non-null wide character was rec‐
37 ognized. It returns 0, if a null wide character was recognized. It
38 returns (size_t) -1 and sets errno to EILSEQ, if an invalid multibyte
39 sequence was encountered. It returns (size_t) -2 if it couldn't parse
40 a complete multibyte character, meaning that n should be increased.
41
43 For an explanation of the terms used in this section, see at‐
44 tributes(7).
45
46 ┌──────────────────────────┬───────────────┬───────────────────────────┐
47 │Interface │ Attribute │ Value │
48 ├──────────────────────────┼───────────────┼───────────────────────────┤
49 │mbrlen() │ Thread safety │ MT-Unsafe race:mbrlen/!ps │
50 └──────────────────────────┴───────────────┴───────────────────────────┘
51
53 POSIX.1-2001, POSIX.1-2008, C99.
54
56 The behavior of mbrlen() depends on the LC_CTYPE category of the cur‐
57 rent locale.
58
60 mbrtowc(3)
61
63 This page is part of release 5.13 of the Linux man-pages project. A
64 description of the project, information about reporting bugs, and the
65 latest version of this page, can be found at
66 https://www.kernel.org/doc/man-pages/.
67
68
69
70GNU 2021-03-22 MBRLEN(3)