]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mbrlen.3
man*/: ffix (un-bracket tables)
[thirdparty/man-pages.git] / man3 / mbrlen.3
CommitLineData
a1eaacb1 1'\" t
fea681da
MK
2.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
3.\"
e4a74ca8 4.\" SPDX-License-Identifier: GPL-2.0-or-later
fea681da
MK
5.\"
6.\" References consulted:
7.\" GNU glibc-2 source code and manual
8.\" Dinkumware C library reference http://www.dinkumware.com/
008f1ecc 9.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
fea681da
MK
10.\" ISO/IEC 9899:1999
11.\"
4c1c5274 12.TH mbrlen 3 (date) "Linux man-pages (unreleased)"
fea681da
MK
13.SH NAME
14mbrlen \- determine number of bytes in next multibyte character
3391a6d6
AC
15.SH LIBRARY
16Standard C library
8fc3b2cf 17.RI ( libc ", " \-lc )
fea681da
MK
18.SH SYNOPSIS
19.nf
20.B #include <wchar.h>
68e4db0a 21.PP
1eed67e7 22.BI "size_t mbrlen(const char " s "[restrict ." n "], size_t " n ,
95bc7a76 23.BI " mbstate_t *restrict " ps );
fea681da
MK
24.fi
25.SH DESCRIPTION
60a90ecd
MK
26The
27.BR mbrlen ()
35cfd378
MK
28function inspects at most
29.I n
30bytes of the multibyte
31string starting at
32.I s
33and extracts the next complete multibyte character.
34It updates the shift state
35.IR *ps .
c13182ef 36If the multibyte character is not the
fea681da 37null wide character, it returns the number of bytes that were consumed from
35cfd378 38.IR s .
c13182ef 39If the multibyte character is the null wide character, it resets the
35cfd378
MK
40shift state
41.I *ps
42to the initial state and returns 0.
fea681da 43.PP
35cfd378 44If the
1ae6b2c7 45.I n
35cfd378
MK
46bytes starting at
47.I s
48do not contain a complete multibyte
60a90ecd
MK
49character,
50.BR mbrlen ()
35cfd378
MK
51returns
52.IR "(size_t)\ \-2" .
c13182ef 53This can happen even if
35cfd378
MK
54.I n
55>=
56.IR MB_CUR_MAX ,
57if the multibyte string contains redundant shift
fea681da
MK
58sequences.
59.PP
35cfd378
MK
60If the multibyte string starting at
61.I s
62contains an invalid multibyte
60a90ecd
MK
63sequence before the next complete character,
64.BR mbrlen ()
65returns
1ae6b2c7 66.I (size_t)\ \-1
35cfd378
MK
67and sets
68.I errno
69to
70.BR EILSEQ .
c13182ef 71In this case,
35cfd378
MK
72the effects on
73.I *ps
74are undefined.
fea681da 75.PP
35cfd378
MK
76If
77.I ps
b437fdd9 78is NULL, a static anonymous state known only to the
d9a10d9d
MK
79.BR mbrlen ()
80function is used instead.
47297adb 81.SH RETURN VALUE
60a90ecd
MK
82The
83.BR mbrlen ()
84function returns the number of bytes
c13182ef 85parsed from the multibyte
35cfd378
MK
86sequence starting at
87.IR s ,
88if a non-null wide character was recognized.
c13182ef 89It returns 0, if a null wide character was recognized.
7d2cb9d5 90It returns
009df872 91.I "(size_t)\ \-1"
35cfd378
MK
92and sets
93.I errno
94to
95.BR EILSEQ ,
96if an invalid multibyte sequence was
c13182ef 97encountered.
35cfd378 98It returns
1ae6b2c7 99.I (size_t)\ \-2
35cfd378
MK
100if it couldn't parse a complete multibyte
101character, meaning that
102.I n
103should be increased.
6c2ec40d 104.SH ATTRIBUTES
fd35a2c6
PH
105For an explanation of the terms used in this section, see
106.BR attributes (7).
107.TS
108allbox;
c466875e 109lbx lb lb
fd35a2c6
PH
110l l l.
111Interface Attribute Value
112T{
9e54434e
BR
113.na
114.nh
6c2ec40d 115.BR mbrlen ()
fd35a2c6
PH
116T} Thread safety MT-Unsafe race:mbrlen/!ps
117.TE
c466875e 118.sp 1
3113c7f3 119.SH STANDARDS
4131356c
AC
120C11, POSIX.1-2008.
121.SH HISTORY
122POSIX.1-2001, C99.
fea681da 123.SH NOTES
d9bfdb9c 124The behavior of
60a90ecd 125.BR mbrlen ()
1274071a
MK
126depends on the
127.B LC_CTYPE
128category of the
fea681da 129current locale.
47297adb 130.SH SEE ALSO
e37e3282 131.BR mbrtowc (3)