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  a  NULL pointer, a static anonymous state only known to the
31       mbrlen() 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

CONFORMING TO

42       C99.
43

NOTES

45       The  behavior  of mbrlen() depends on the LC_CTYPE category of the cur‐
46       rent locale.
47

SEE ALSO

49       mbrtowc(3)
50

COLOPHON

52       This page is part of release 3.25 of the Linux  man-pages  project.   A
53       description  of  the project, and information about reporting bugs, can
54       be found at http://www.kernel.org/doc/man-pages/.
55
56
57
58GNU                               1999-07-25                         MBRLEN(3)
Impressum