OSDN Git Service

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