]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/mbrlen.3
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex...
[thirdparty/man-pages.git] / man3 / mbrlen.3
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
16 mbrlen \- 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
24 The
25 .BR mbrlen ()
26 function inspects at most \fIn\fP bytes of the multibyte
27 string starting at \fIs\fP and extracts the next complete multibyte character.
28 It updates the shift state \fI*ps\fP.
29 If the multibyte character is not the
30 null wide character, it returns the number of bytes that were consumed from
31 \fIs\fP.
32 If the multibyte character is the null wide character, it resets the
33 shift state \fI*ps\fP to the initial state and returns 0.
34 .PP
35 If the \fIn\fP bytes starting at \fIs\fP do not contain a complete multibyte
36 character,
37 .BR mbrlen ()
38 returns \fI(size_t)\ \-2\fP.
39 This can happen even if
40 \fIn\fP >= \fIMB_CUR_MAX\fP, if the multibyte string contains redundant shift
41 sequences.
42 .PP
43 If the multibyte string starting at \fIs\fP contains an invalid multibyte
44 sequence before the next complete character,
45 .BR mbrlen ()
46 returns
47 \fI(size_t)\ \-1\fP and sets \fIerrno\fP to \fBEILSEQ\fP.
48 In this case,
49 the effects on \fI*ps\fP are undefined.
50 .PP
51 If \fIps\fP is a NULL pointer, a static anonymous state only known to the
52 .BR mbrlen ()
53 function is used instead.
54 .SH RETURN VALUE
55 The
56 .BR mbrlen ()
57 function returns the number of bytes
58 parsed from the multibyte
59 sequence starting at \fIs\fP, if a non-null wide character was recognized.
60 It returns 0, if a null wide character was recognized.
61 It returns
62 .I "(size_t)\ \-1"
63 and sets \fIerrno\fP to \fBEILSEQ\fP, if an invalid multibyte sequence was
64 encountered.
65 It returns \fI(size_t)\ \-2\fP if it couldn't parse a complete multibyte
66 character, meaning that \fIn\fP should be increased.
67 .SH CONFORMING TO
68 C99.
69 .SH NOTES
70 The behavior of
71 .BR mbrlen ()
72 depends on the
73 .B LC_CTYPE
74 category of the
75 current locale.
76 .SH SEE ALSO
77 .BR mbrtowc (3)