]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mbrlen.3
pow.3: Minor tweak to BUGS
[thirdparty/man-pages.git] / man3 / mbrlen.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 MBRLEN 3 2015-08-08 "GNU" "Linux Programmer's Manual"
fea681da
MK
17.SH NAME
18mbrlen \- determine number of bytes in next multibyte character
19.SH SYNOPSIS
20.nf
21.B #include <wchar.h>
68e4db0a 22.PP
fea681da
MK
23.BI "size_t mbrlen(const char *" s ", size_t " n ", mbstate_t *" ps );
24.fi
25.SH DESCRIPTION
60a90ecd
MK
26The
27.BR mbrlen ()
35cfd378
MK
28function inspects at most
29.I n
30bytes of the multibyte
31string starting at
32.I s
33and extracts the next complete multibyte character.
34It updates the shift state
35.IR *ps .
c13182ef 36If the multibyte character is not the
fea681da 37null wide character, it returns the number of bytes that were consumed from
35cfd378 38.IR s .
c13182ef 39If the multibyte character is the null wide character, it resets the
35cfd378
MK
40shift state
41.I *ps
42to the initial state and 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 mbrlen ()
35cfd378
MK
51returns
52.IR "(size_t)\ \-2" .
c13182ef 53This can happen even if
35cfd378
MK
54.I n
55>=
56.IR MB_CUR_MAX ,
57if the multibyte string contains redundant shift
fea681da
MK
58sequences.
59.PP
35cfd378
MK
60If the multibyte string starting at
61.I s
62contains an invalid multibyte
60a90ecd
MK
63sequence before the next complete character,
64.BR mbrlen ()
65returns
35cfd378
MK
66.IR "(size_t)\ \-1"
67and sets
68.I errno
69to
70.BR EILSEQ .
c13182ef 71In this case,
35cfd378
MK
72the effects on
73.I *ps
74are undefined.
fea681da 75.PP
35cfd378
MK
76If
77.I ps
b437fdd9 78is NULL, a static anonymous state known only to the
d9a10d9d
MK
79.BR mbrlen ()
80function is used instead.
47297adb 81.SH RETURN VALUE
60a90ecd
MK
82The
83.BR mbrlen ()
84function returns the number of bytes
c13182ef 85parsed from the multibyte
35cfd378
MK
86sequence starting at
87.IR s ,
88if a non-null wide character was recognized.
c13182ef 89It returns 0, if a null wide character was recognized.
7d2cb9d5 90It returns
009df872 91.I "(size_t)\ \-1"
35cfd378
MK
92and sets
93.I errno
94to
95.BR EILSEQ ,
96if an invalid multibyte sequence was
c13182ef 97encountered.
35cfd378
MK
98It returns
99.IR "(size_t)\ \-2"
100if it couldn't parse a complete multibyte
101character, meaning that
102.I n
103should be increased.
6c2ec40d 104.SH ATTRIBUTES
fd35a2c6
PH
105For an explanation of the terms used in this section, see
106.BR attributes (7).
107.TS
108allbox;
109lb lb lb
110l l l.
111Interface Attribute Value
112T{
6c2ec40d 113.BR mbrlen ()
fd35a2c6
PH
114T} Thread safety MT-Unsafe race:mbrlen/!ps
115.TE
47297adb 116.SH CONFORMING TO
5f11381b 117POSIX.1-2001, POSIX.1-2008, C99.
fea681da 118.SH NOTES
d9bfdb9c 119The behavior of
60a90ecd 120.BR mbrlen ()
1274071a
MK
121depends on the
122.B LC_CTYPE
123category of the
fea681da 124current locale.
47297adb 125.SH SEE ALSO
e37e3282 126.BR mbrtowc (3)