]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mblen.3
fanotify_init.2: ffix
[thirdparty/man-pages.git] / man3 / mblen.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
89e3ffe9 3.\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
fea681da
MK
4.\" This is free documentation; you can redistribute it and/or
5.\" modify it under the terms of the GNU General Public License as
6.\" published by the Free Software Foundation; either version 2 of
7.\" the License, or (at your option) any later version.
fe382ebf 8.\" %%%LICENSE_END
fea681da
MK
9.\"
10.\" References consulted:
11.\" GNU glibc-2 source code and manual
12.\" Dinkumware C library reference http://www.dinkumware.com/
008f1ecc 13.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
fea681da
MK
14.\" ISO/IEC 9899:1999
15.\"
460495ca 16.TH MBLEN 3 2015-08-08 "GNU" "Linux Programmer's Manual"
fea681da
MK
17.SH NAME
18mblen \- determine number of bytes in next multibyte character
19.SH SYNOPSIS
20.nf
21.B #include <stdlib.h>
22.sp
23.BI "int mblen(const char *" s ", size_t " n );
24.fi
25.SH DESCRIPTION
35cfd378
MK
26If
27.I s
b437fdd9 28is not NULL, the
60a90ecd
MK
29.BR mblen ()
30function inspects at most
35cfd378
MK
31.I n
32bytes of the multibyte string starting at
33.I s
34and extracts the
c13182ef 35next complete multibyte character.
33a0ccb2 36It uses a static anonymous shift state known only to the
d7ba51f9
MK
37.BR mblen ()
38function.
c13182ef 39If the multibyte character is not the null wide
35cfd378
MK
40character, it returns the number of bytes that were consumed from
41.IR s .
c13182ef 42If the multibyte character is the null wide character, it returns 0.
fea681da 43.PP
35cfd378 44If the
51700fd7 45.IR n
35cfd378
MK
46bytes starting at
47.I s
48do not contain a complete multibyte
60a90ecd
MK
49character,
50.BR mblen ()
51returns \-1.
c13182ef 52This can happen even if
35cfd378
MK
53.I n
54is greater than or equal to
55.IR MB_CUR_MAX ,
d7ba51f9 56if the multibyte string contains redundant shift sequences.
fea681da 57.PP
35cfd378
MK
58If the multibyte string starting at
59.I s
60contains an invalid multibyte
60a90ecd
MK
61sequence before the next complete character,
62.BR mblen ()
00e28710 63also returns \-1.
fea681da 64.PP
35cfd378
MK
65If
66.I s
b437fdd9 67is NULL, the
60a90ecd
MK
68.BR mblen ()
69function
008f1ecc 70.\" The Dinkumware doc and the Single UNIX specification say this, but
fea681da 71.\" glibc doesn't implement this.
33a0ccb2 72resets the shift state, known to only this function, to the initial state, and
c7094399 73returns nonzero if the encoding has nontrivial shift state, or zero if the
fea681da 74encoding is stateless.
47297adb 75.SH RETURN VALUE
60a90ecd
MK
76The
77.BR mblen ()
78function returns the number of
c13182ef 79bytes parsed from the multibyte
35cfd378
MK
80sequence starting at
81.IR s ,
82if a non-null wide character was recognized.
c13182ef
MK
83It returns 0, if a null wide character was recognized.
84It returns \-1, if an
fea681da
MK
85invalid multibyte sequence was encountered or if it couldn't parse a complete
86multibyte character.
de541d4b 87.SH ATTRIBUTES
d355517b
PH
88For an explanation of the terms used in this section, see
89.BR attributes (7).
90.TS
91allbox;
92lb lb lb
93l l l.
94Interface Attribute Value
95T{
de541d4b 96.BR mblen ()
ae47f91a 97T} Thread safety MT-Unsafe race
d355517b 98.TE
47297adb 99.SH CONFORMING TO
c2200cab 100POSIX.1-2001, POSIX.1-2008, C99.
fea681da 101.SH NOTES
d9bfdb9c 102The behavior of
60a90ecd 103.BR mblen ()
1274071a
MK
104depends on the
105.B LC_CTYPE
106category of the
fea681da
MK
107current locale.
108.PP
60a90ecd
MK
109The function
110.BR mbrlen (3)
111provides a better interface to the same
fea681da 112functionality.
47297adb 113.SH SEE ALSO
e37e3282 114.BR mbrlen (3)