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