]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mblen.3
proc.5: wfix (mainly "only")
[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.\"
16.TH MBLEN 3 1999-07-25 "GNU" "Linux Programmer's Manual"
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
60a90ecd
MK
26If \fIs\fP is not a NULL pointer, the
27.BR mblen ()
28function inspects at most
fea681da 29\fIn\fP bytes of the multibyte string starting at \fIs\fP and extracts the
c13182ef
MK
30next complete multibyte character.
31It uses a static anonymous shift state only
d7ba51f9
MK
32known to the
33.BR mblen ()
34function.
c13182ef
MK
35If the multibyte character is not the null wide
36character, it returns the number of bytes that were consumed from \fIs\fP.
37If the multibyte character is the null wide character, it returns 0.
fea681da
MK
38.PP
39If the \fIn\fP bytes starting at \fIs\fP do not contain a complete multibyte
60a90ecd
MK
40character,
41.BR mblen ()
42returns \-1.
c13182ef 43This can happen even if
d7ba51f9
MK
44\fIn\fP is greater than or equal to \fIMB_CUR_MAX\fP,
45if the multibyte string contains redundant shift sequences.
fea681da
MK
46.PP
47If the multibyte string starting at \fIs\fP contains an invalid multibyte
60a90ecd
MK
48sequence before the next complete character,
49.BR mblen ()
00e28710 50also returns \-1.
fea681da 51.PP
60a90ecd
MK
52If \fIs\fP is a NULL pointer, the
53.BR mblen ()
54function
008f1ecc 55.\" The Dinkumware doc and the Single UNIX specification say this, but
fea681da
MK
56.\" glibc doesn't implement this.
57resets the shift state, only known to this function, to the initial state, and
c7094399 58returns nonzero if the encoding has nontrivial shift state, or zero if the
fea681da 59encoding is stateless.
47297adb 60.SH RETURN VALUE
60a90ecd
MK
61The
62.BR mblen ()
63function returns the number of
c13182ef 64bytes parsed from the multibyte
fea681da 65sequence starting at \fIs\fP, if a non-null wide character was recognized.
c13182ef
MK
66It returns 0, if a null wide character was recognized.
67It returns \-1, if an
fea681da
MK
68invalid multibyte sequence was encountered or if it couldn't parse a complete
69multibyte character.
47297adb 70.SH CONFORMING TO
44a2c328 71C99.
fea681da 72.SH NOTES
d9bfdb9c 73The behavior of
60a90ecd 74.BR mblen ()
1274071a
MK
75depends on the
76.B LC_CTYPE
77category of the
fea681da
MK
78current locale.
79.PP
60a90ecd
MK
80The function
81.BR mbrlen (3)
82provides a better interface to the same
fea681da 83functionality.
47297adb 84.SH SEE ALSO
e37e3282 85.BR mbrlen (3)