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 null
17       wide character, it returns the number of bytes that were consumed  from
18       s. If the multibyte character is the null wide character, it resets the
19       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

SEE ALSO

45       mbrtowc(3)
46

NOTES

48       The  behaviour of mbrlen() depends on the LC_CTYPE category of the cur‐
49       rent locale.
50
51
52
53GNU                               1999-07-25                         MBRLEN(3)
Impressum