]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mbrlen.3
ffix
[thirdparty/man-pages.git] / man3 / mbrlen.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
3.\" This is free documentation; you can redistribute it and/or
4.\" modify it under the terms of the GNU General Public License as
5.\" published by the Free Software Foundation; either version 2 of
6.\" the License, or (at your option) any later version.
7.\"
8.\" References consulted:
9.\" GNU glibc-2 source code and manual
10.\" Dinkumware C library reference http://www.dinkumware.com/
11.\" OpenGroup's Single Unix specification http://www.UNIX-systems.org/online.html
12.\" ISO/IEC 9899:1999
13.\"
14.TH MBRLEN 3 1999-07-25 "GNU" "Linux Programmer's Manual"
15.SH NAME
16mbrlen \- determine number of bytes in next multibyte character
17.SH SYNOPSIS
18.nf
19.B #include <wchar.h>
20.sp
21.BI "size_t mbrlen(const char *" s ", size_t " n ", mbstate_t *" ps );
22.fi
23.SH DESCRIPTION
60a90ecd
MK
24The
25.BR mbrlen ()
26function inspects at most \fIn\fP bytes of the multibyte
fea681da 27string starting at \fIs\fP and extracts the next complete multibyte character.
c13182ef
MK
28It updates the shift state \fI*ps\fP.
29If the multibyte character is not the
fea681da 30null wide character, it returns the number of bytes that were consumed from
c13182ef
MK
31\fIs\fP.
32If the multibyte character is the null wide character, it resets the
fea681da
MK
33shift state \fI*ps\fP to the initial state and returns 0.
34.PP
35If the \fIn\fP bytes starting at \fIs\fP do not contain a complete multibyte
60a90ecd
MK
36character,
37.BR mbrlen ()
38returns \fI(size_t)(\-2)\fP.
c13182ef 39This can happen even if
fea681da
MK
40\fIn\fP >= \fIMB_CUR_MAX\fP, if the multibyte string contains redundant shift
41sequences.
42.PP
43If the multibyte string starting at \fIs\fP contains an invalid multibyte
60a90ecd
MK
44sequence before the next complete character,
45.BR mbrlen ()
46returns
c13182ef
MK
47\fI(size_t)(\-1)\fP and sets \fIerrno\fP to \fBEILSEQ\fP.
48In this case,
fea681da
MK
49the effects on \fI*ps\fP are undefined.
50.PP
51If \fIps\fP is a NULL pointer, a static anonymous state only known to the
52mbrlen function is used instead.
53.SH "RETURN VALUE"
60a90ecd
MK
54The
55.BR mbrlen ()
56function returns the number of bytes
c13182ef 57parsed from the multibyte
fea681da 58sequence starting at \fIs\fP, if a non-null wide character was recognized.
c13182ef
MK
59It returns 0, if a null wide character was recognized.
60It returns (size_t)(\-1)
dcec8eb5 61and sets \fIerrno\fP to \fBEILSEQ\fP, if an invalid multibyte sequence was
c13182ef
MK
62encountered.
63It returns (size_t)(\-2) if it couldn't parse a complete multibyte
fea681da
MK
64character, meaning that \fIn\fP should be increased.
65.SH "CONFORMING TO"
68e1685c 66C99
fea681da 67.SH NOTES
d9bfdb9c 68The behavior of
60a90ecd 69.BR mbrlen ()
1274071a
MK
70depends on the
71.B LC_CTYPE
72category of the
fea681da 73current locale.
e37e3282
MK
74.SH "SEE ALSO"
75.BR mbrtowc (3)