]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mblen.3
mbrlen.3: Reformat thread-safety information
[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.\"
f9293d98 16.TH MBLEN 3 2013-06-21 "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
PH
87.SH ATTRIBUTES
88.SS Multithreading (see pthreads(7))
89The
90.BR mblen ()
91function is not thread-safe.
47297adb 92.SH CONFORMING TO
44a2c328 93C99.
fea681da 94.SH NOTES
d9bfdb9c 95The behavior of
60a90ecd 96.BR mblen ()
1274071a
MK
97depends on the
98.B LC_CTYPE
99category of the
fea681da
MK
100current locale.
101.PP
60a90ecd
MK
102The function
103.BR mbrlen (3)
104provides a better interface to the same
fea681da 105functionality.
47297adb 106.SH SEE ALSO
e37e3282 107.BR mbrlen (3)