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

NAME

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

SYNOPSIS

9       #include <stdlib.h>
10
11       int mblen(const char *s, size_t n);
12

DESCRIPTION

14       If  s is not NULL, the mblen() function inspects at most n bytes of the
15       multibyte string starting at s and extracts the next complete multibyte
16       character.   It  uses  a static anonymous shift state known only to the
17       mblen() function.  If the multibyte character  is  not  the  null  wide
18       character,  it  returns  the number of bytes that were consumed from s.
19       If the multibyte character is the null wide character, it returns 0.
20
21       If the n bytes starting at s do not contain a complete multibyte  char‐
22       acter,  mblen()  returns -1.  This can happen even if n is greater than
23       or equal to MB_CUR_MAX, if  the  multibyte  string  contains  redundant
24       shift sequences.
25
26       If  the  multibyte  string  starting at s contains an invalid multibyte
27       sequence before the next complete character, mblen() also returns -1.
28
29       If s is NULL, the mblen() function resets the  shift  state,  known  to
30       only  this  function,  to the initial state, and returns nonzero if the
31       encoding has nontrivial shift state, or zero if the encoding is  state‐
32       less.
33

RETURN VALUE

35       The mblen() function returns the number of bytes parsed from the multi‐
36       byte sequence starting at s, if a non-null wide  character  was  recog‐
37       nized.   It  returns  0,  if  a null wide character was recognized.  It
38       returns -1, if an invalid multibyte sequence was encountered or  if  it
39       couldn't parse a complete multibyte character.
40

ATTRIBUTES

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

CONFORMING TO

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

NOTES

54       The behavior of mblen() depends on the LC_CTYPE category of the current
55       locale.
56
57       The  function  mbrlen(3)  provides a better interface to the same func‐
58       tionality.
59

SEE ALSO

61       mbrlen(3)
62

COLOPHON

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