]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mblen.3
man*/: ffix (un-bracket tables)
[thirdparty/man-pages.git] / man3 / mblen.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 mblen 3 (date) "Linux man-pages (unreleased)"
fea681da
MK
13.SH NAME
14mblen \- determine number of bytes in next multibyte character
e725fd6e
AC
15.SH LIBRARY
16Standard C library
8fc3b2cf 17.RI ( libc ", " \-lc )
fea681da
MK
18.SH SYNOPSIS
19.nf
20.B #include <stdlib.h>
68e4db0a 21.PP
1eed67e7 22.BI "int mblen(const char " s [. n "], size_t " n );
fea681da
MK
23.fi
24.SH DESCRIPTION
35cfd378
MK
25If
26.I s
b437fdd9 27is not NULL, the
60a90ecd
MK
28.BR mblen ()
29function inspects at most
35cfd378
MK
30.I n
31bytes of the multibyte string starting at
32.I s
33and extracts the
c13182ef 34next complete multibyte character.
33a0ccb2 35It uses a static anonymous shift state known only to the
d7ba51f9
MK
36.BR mblen ()
37function.
c13182ef 38If the multibyte character is not the null wide
35cfd378
MK
39character, it returns the number of bytes that were consumed from
40.IR s .
c13182ef 41If the multibyte character is the null wide character, it returns 0.
fea681da 42.PP
35cfd378 43If the
1ae6b2c7 44.I n
35cfd378
MK
45bytes starting at
46.I s
47do not contain a complete multibyte
60a90ecd
MK
48character,
49.BR mblen ()
50returns \-1.
c13182ef 51This can happen even if
35cfd378
MK
52.I n
53is greater than or equal to
54.IR MB_CUR_MAX ,
d7ba51f9 55if the multibyte string contains redundant shift sequences.
fea681da 56.PP
35cfd378
MK
57If the multibyte string starting at
58.I s
59contains an invalid multibyte
60a90ecd
MK
60sequence before the next complete character,
61.BR mblen ()
00e28710 62also returns \-1.
fea681da 63.PP
35cfd378
MK
64If
65.I s
b437fdd9 66is NULL, the
60a90ecd
MK
67.BR mblen ()
68function
008f1ecc 69.\" The Dinkumware doc and the Single UNIX specification say this, but
fea681da 70.\" glibc doesn't implement this.
33a0ccb2 71resets the shift state, known to only this function, to the initial state, and
c7094399 72returns nonzero if the encoding has nontrivial shift state, or zero if the
fea681da 73encoding is stateless.
47297adb 74.SH RETURN VALUE
60a90ecd
MK
75The
76.BR mblen ()
77function returns the number of
c13182ef 78bytes parsed from the multibyte
35cfd378
MK
79sequence starting at
80.IR s ,
81if a non-null wide character was recognized.
c13182ef
MK
82It returns 0, if a null wide character was recognized.
83It returns \-1, if an
fea681da
MK
84invalid multibyte sequence was encountered or if it couldn't parse a complete
85multibyte character.
de541d4b 86.SH ATTRIBUTES
d355517b
PH
87For an explanation of the terms used in this section, see
88.BR attributes (7).
89.TS
90allbox;
c466875e 91lbx lb lb
d355517b
PH
92l l l.
93Interface Attribute Value
94T{
9e54434e
BR
95.na
96.nh
de541d4b 97.BR mblen ()
ae47f91a 98T} Thread safety MT-Unsafe race
d355517b 99.TE
c466875e 100.sp 1
4131356c
AC
101.SH VERSIONS
102The function
103.BR mbrlen (3)
104provides a better interface to the same
105functionality.
3113c7f3 106.SH STANDARDS
4131356c
AC
107C11, POSIX.1-2008.
108.SH HISTORY
109POSIX.1-2001, C99.
fea681da 110.SH NOTES
d9bfdb9c 111The behavior of
60a90ecd 112.BR mblen ()
1274071a
MK
113depends on the
114.B LC_CTYPE
115category of the
fea681da 116current locale.
47297adb 117.SH SEE ALSO
e37e3282 118.BR mbrlen (3)