1MBLEN(3P)                  POSIX Programmer's Manual                 MBLEN(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       mblen — get number of bytes in a character
13

SYNOPSIS

15       #include <stdlib.h>
16
17       int mblen(const char *s, size_t n);
18

DESCRIPTION

20       The functionality described on this reference page is aligned with  the
21       ISO C  standard.  Any  conflict between the requirements described here
22       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
23       defers to the ISO C standard.
24
25       If s is not a null pointer, mblen() shall determine the number of bytes
26       constituting the character pointed to by  s.   Except  that  the  shift
27       state of mbtowc() is not affected, it shall be equivalent to:
28
29
30           mbtowc((wchar_t *)0, s, n);
31
32       The  implementation shall behave as if no function defined in this vol‐
33       ume of POSIX.1‐2017 calls mblen().
34
35       The behavior of this function is affected by the LC_CTYPE  category  of
36       the current locale. For a state-dependent encoding, this function shall
37       be placed into its initial state by a  call  for  which  its  character
38       pointer  argument,  s,  is  a  null pointer. Subsequent calls with s as
39       other than a null pointer shall cause the internal state of  the  func‐
40       tion  to be altered as necessary. A call with s as a null pointer shall
41       cause this function to return a non-zero value if encodings have  state
42       dependency,  and  0  otherwise.  If  the implementation employs special
43       bytes to change the shift state, these bytes shall not produce separate
44       wide-character  codes, but shall be grouped with an adjacent character.
45       Changing the LC_CTYPE category causes the shift state of this  function
46       to be unspecified.
47
48       The mblen() function need not be thread-safe.
49

RETURN VALUE

51       If  s is a null pointer, mblen() shall return a non-zero or 0 value, if
52       character encodings, respectively, do or do  not  have  state-dependent
53       encodings.  If  s  is not a null pointer, mblen() shall either return 0
54       (if s points to the null byte), or return the number of bytes that con‐
55       stitute  the character (if the next n or fewer bytes form a valid char‐
56       acter), or return -1 (if they do not form a valid  character)  and  may
57       set  errno  to indicate the error.  In no case shall the value returned
58       be greater than n or the value of the {MB_CUR_MAX} macro.
59

ERRORS

61       The mblen() function may fail if:
62
63       EILSEQ An invalid character sequence is detected. In the  POSIX  locale
64              an  [EILSEQ]  error cannot occur since all byte values are valid
65              characters.
66
67       The following sections are informative.
68

EXAMPLES

70       None.
71

APPLICATION USAGE

73       None.
74

RATIONALE

76       None.
77

FUTURE DIRECTIONS

79       None.
80

SEE ALSO

82       mbtowc(), mbstowcs(), wctomb(), wcstombs()
83
84       The Base Definitions volume of POSIX.1‐2017, <stdlib.h>
85
87       Portions of this text are reprinted and reproduced in  electronic  form
88       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
89       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
90       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
91       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
92       event of any discrepancy between this version and the original IEEE and
93       The Open Group Standard, the original IEEE and The Open Group  Standard
94       is  the  referee document. The original Standard can be obtained online
95       at http://www.opengroup.org/unix/online.html .
96
97       Any typographical or formatting errors that appear  in  this  page  are
98       most likely to have been introduced during the conversion of the source
99       files to man page format. To report such errors,  see  https://www.ker
100       nel.org/doc/man-pages/reporting_bugs.html .
101
102
103
104IEEE/The Open Group                  2017                            MBLEN(3P)
Impressum