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 *s, size_t n, mbstate_t *ps);
12
14 The mbrlen() function inspects at most n bytes of the multibyte string
15 starting at s and extracts the next complete multibyte character. It
16 updates the shift state *ps. If the multibyte character is not the
17 null wide character, it returns the number of bytes that were consumed
18 from s. If the multibyte character is the null wide character, it
19 resets the shift state *ps to the initial state and returns 0.
20
21 If the n bytes starting at s do not contain a complete multibyte char‐
22 acter, mbrlen() returns (size_t) -2. This can happen even if n >=
23 MB_CUR_MAX, if 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, mbrlen() returns
27 (size_t) -1 and sets errno to EILSEQ. In this case, the effects on *ps
28 are undefined.
29
30 If ps is a NULL pointer, a static anonymous state known only to the
31 mbrlen() function is used instead.
32
34 The mbrlen() function returns the number of bytes parsed from the
35 multibyte sequence starting at s, if a non-null wide character was rec‐
36 ognized. It returns 0, if a null wide character was recognized. It
37 returns (size_t) -1 and sets errno to EILSEQ, if an invalid multibyte
38 sequence was encountered. It returns (size_t) -2 if it couldn't parse
39 a complete multibyte character, meaning that n should be increased.
40
42 Multithreading (see pthreads(7))
43 The mbrlen() function is thread-safe with exceptions. It is not
44 thread-safe if called with a NULL ps parameter.
45
47 C99.
48
50 The behavior of mbrlen() depends on the LC_CTYPE category of the cur‐
51 rent locale.
52
54 mbrtowc(3)
55
57 This page is part of release 3.53 of the Linux man-pages project. A
58 description of the project, and information about reporting bugs, can
59 be found at http://www.kernel.org/doc/man-pages/.
60
61
62
63GNU 2013-06-21 MBRLEN(3)