1MBRLEN(3)                  Linux Programmer's Manual                 MBRLEN(3)
2
3
4

NAME

6       mbrlen - determine number of bytes in next multibyte character
7

SYNOPSIS

9       #include <wchar.h>
10
11       size_t mbrlen(const char *s, size_t n, mbstate_t *ps);
12

DESCRIPTION

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  NULL,  a  static anonymous state known only to the mbrlen()
31       function is used instead.
32

RETURN VALUE

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

ATTRIBUTES

42       For   an   explanation   of   the  terms  used  in  this  section,  see
43       attributes(7).
44
45       ┌──────────┬───────────────┬───────────────────────────┐
46Interface Attribute     Value                     
47       ├──────────┼───────────────┼───────────────────────────┤
48mbrlen()  │ Thread safety │ MT-Unsafe race:mbrlen/!ps │
49       └──────────┴───────────────┴───────────────────────────┘

CONFORMING TO

51       POSIX.1-2001, POSIX.1-2008, C99.
52

NOTES

54       The behavior of mbrlen() depends on the LC_CTYPE category of  the  cur‐
55       rent locale.
56

SEE ALSO

58       mbrtowc(3)
59

COLOPHON

61       This  page  is  part of release 5.02 of the Linux man-pages project.  A
62       description of the project, information about reporting bugs,  and  the
63       latest     version     of     this    page,    can    be    found    at
64       https://www.kernel.org/doc/man-pages/.
65
66
67
68GNU                               2015-08-08                         MBRLEN(3)
Impressum