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
11

NAME

13       mbrlen — get number of bytes in a character (restartable)
14

SYNOPSIS

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

DESCRIPTION

22       The functionality described on this reference page is aligned with  the
23       ISO C  standard.  Any  conflict between the requirements described here
24       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
25       defers to the ISO C standard.
26
27       If  s  is  not  a  null pointer, mbrlen() shall determine the number of
28       bytes constituting the character pointed to by s.  It shall be  equiva‐
29       lent to:
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‐2008 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.
77
78       The mbrlen() function may fail if:
79
80       EINVAL ps  points  to  an  object  that  contains an invalid conversion
81              state.
82
83       The following sections are informative.
84

EXAMPLES

86       None.
87

APPLICATION USAGE

89       None.
90

RATIONALE

92       None.
93

FUTURE DIRECTIONS

95       None.
96

SEE ALSO

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