1mbrlen(3)                  Library Functions Manual                  mbrlen(3)
2
3
4

NAME

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

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <wchar.h>
13
14       size_t mbrlen(const char s[restrict .n], size_t n,
15                     mbstate_t *restrict ps);
16

DESCRIPTION

18       The  mbrlen() function inspects at most n bytes of the multibyte string
19       starting at s and extracts the next complete multibyte  character.   It
20       updates  the  shift  state  *ps.  If the multibyte character is not the
21       null wide character, it returns the number of bytes that were  consumed
22       from  s.  If the multibyte character is the null wide character, it re‐
23       sets the shift state *ps to the initial state and returns 0.
24
25       If the n bytes starting at s do not contain a complete multibyte  char‐
26       acter,  mbrlen()  returns  (size_t) -2.   This  can happen even if n >=
27       MB_CUR_MAX, if the multibyte string contains redundant shift sequences.
28
29       If the multibyte string starting at s contains an invalid multibyte se‐
30       quence before the next complete character, mbrlen() returns (size_t) -1
31       and sets errno to EILSEQ.  In this case, the effects on *ps  are  unde‐
32       fined.
33
34       If  ps  is  NULL,  a  static anonymous state known only to the mbrlen()
35       function is used instead.
36

RETURN VALUE

38       The mbrlen() function returns the  number  of  bytes  parsed  from  the
39       multibyte sequence starting at s, if a non-null wide character was rec‐
40       ognized.  It returns 0, if a null wide character  was  recognized.   It
41       returns  (size_t) -1  and sets errno to EILSEQ, if an invalid multibyte
42       sequence was encountered.  It returns (size_t) -2 if it couldn't  parse
43       a complete multibyte character, meaning that n should be increased.
44

ATTRIBUTES

46       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
47       tributes(7).
48
49       ┌──────────────────────────┬───────────────┬───────────────────────────┐
50Interface                 Attribute     Value                     
51       ├──────────────────────────┼───────────────┼───────────────────────────┤
52mbrlen()                  │ Thread safety │ MT-Unsafe race:mbrlen/!ps │
53       └──────────────────────────┴───────────────┴───────────────────────────┘
54

STANDARDS

56       C11, POSIX.1-2008.
57

HISTORY

59       POSIX.1-2001, C99.
60

NOTES

62       The behavior of mbrlen() depends on the LC_CTYPE category of  the  cur‐
63       rent locale.
64

SEE ALSO

66       mbrtowc(3)
67
68
69
70Linux man-pages 6.04              2023-03-30                         mbrlen(3)
Impressum