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