1MBRLEN(3P)                 POSIX Programmer's Manual                MBRLEN(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       mbrlen — get number of bytes in a character (restartable)
13

SYNOPSIS

15       #include <wchar.h>
16
17       size_t mbrlen(const char *restrict s, size_t n,
18           mbstate_t *restrict ps);
19

DESCRIPTION

21       The functionality described on this reference page is aligned with  the
22       ISO C  standard.  Any  conflict between the requirements described here
23       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2017
24       defers to the ISO C standard.
25
26       If  s  is  not  a  null pointer, mbrlen() shall determine the number of
27       bytes constituting the character pointed to by s.  It shall be  equiva‐
28       lent to:
29
30
31           mbstate_t internal;
32           mbrtowc(NULL, s, n, ps != NULL ? ps : &internal);
33
34       If ps is a null pointer, the mbrlen() function shall use its own inter‐
35       nal mbstate_t object, which is initialized at program start-up  to  the
36       initial conversion state. Otherwise, the mbstate_t object pointed to by
37       ps shall be used to completely describe the current conversion state of
38       the  associated  character sequence. The implementation shall behave as
39       if no function defined in this volume of POSIX.1‐2017 calls mbrlen().
40
41       The behavior of this function is affected by the LC_CTYPE  category  of
42       the current locale.
43
44       The  mbrlen() function need not be thread-safe if called with a NULL ps
45       argument.
46
47       The mbrlen() function shall not change the setting of errno if success‐
48       ful.
49

RETURN VALUE

51       The  mbrlen()  function  shall  return  the first of the following that
52       applies:
53
54       0           If the next n or fewer bytes complete  the  character  that
55                   corresponds to the null wide character.
56
57       positive    If  the  next  n or fewer bytes complete a valid character;
58                   the value returned shall be the number of bytes  that  com‐
59                   plete the character.
60
61       (size_t)-2  If  the next n bytes contribute to an incomplete but poten‐
62                   tially valid character, and all  n  bytes  have  been  pro‐
63                   cessed.  When  n has at least the value of the {MB_CUR_MAX}
64                   macro, this case can only occur if s points at  a  sequence
65                   of  redundant  shift  sequences  (for  implementations with
66                   state-dependent encodings).
67
68       (size_t)-1  If an encoding error occurs, in which case the  next  n  or
69                   fewer bytes do not contribute to a complete and valid char‐
70                   acter. In this case, [EILSEQ] shall be stored in errno  and
71                   the conversion state is undefined.
72

ERRORS

74       The mbrlen() function shall fail if:
75
76       EILSEQ An  invalid character sequence is detected.  In the POSIX locale
77              an [EILSEQ] error cannot occur since all byte values  are  valid
78              characters.
79
80       The mbrlen() function may fail if:
81
82       EINVAL ps  points  to  an  object  that  contains an invalid conversion
83              state.
84
85       The following sections are informative.
86

EXAMPLES

88       None.
89

APPLICATION USAGE

91       None.
92

RATIONALE

94       None.
95

FUTURE DIRECTIONS

97       None.
98

SEE ALSO

100       mbsinit(), mbrtowc()
101
102       The Base Definitions volume of POSIX.1‐2017, <wchar.h>
103
105       Portions of this text are reprinted and reproduced in  electronic  form
106       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
107       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
108       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
109       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
110       event of any discrepancy between this version and the original IEEE and
111       The Open Group Standard, the original IEEE and The Open Group  Standard
112       is  the  referee document. The original Standard can be obtained online
113       at http://www.opengroup.org/unix/online.html .
114
115       Any typographical or formatting errors that appear  in  this  page  are
116       most likely to have been introduced during the conversion of the source
117       files to man page format. To report such errors,  see  https://www.ker
118       nel.org/doc/man-pages/reporting_bugs.html .
119
120
121
122IEEE/The Open Group                  2017                           MBRLEN(3P)
Impressum