OSDN Git Service

(split) LDP: Change Makefile to stamp-based compilation
[linuxjm/LDP_man-pages.git] / original / man3 / mblen.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 MBLEN 3  1999-07-25 "GNU" "Linux Programmer's Manual"
17 .SH NAME
18 mblen \- determine number of bytes in next multibyte character
19 .SH SYNOPSIS
20 .nf
21 .B #include <stdlib.h>
22 .sp
23 .BI "int mblen(const char *" s ", size_t " n );
24 .fi
25 .SH DESCRIPTION
26 If \fIs\fP is not a NULL pointer, the
27 .BR mblen ()
28 function inspects at most
29 \fIn\fP bytes of the multibyte string starting at \fIs\fP and extracts the
30 next complete multibyte character.
31 It uses a static anonymous shift state known only to the
32 .BR mblen ()
33 function.
34 If the multibyte character is not the null wide
35 character, it returns the number of bytes that were consumed from \fIs\fP.
36 If the multibyte character is the null wide character, it returns 0.
37 .PP
38 If the \fIn\fP bytes starting at \fIs\fP do not contain a complete multibyte
39 character,
40 .BR mblen ()
41 returns \-1.
42 This can happen even if
43 \fIn\fP is greater than or equal to \fIMB_CUR_MAX\fP,
44 if the multibyte string contains redundant shift sequences.
45 .PP
46 If the multibyte string starting at \fIs\fP contains an invalid multibyte
47 sequence before the next complete character,
48 .BR mblen ()
49 also returns \-1.
50 .PP
51 If \fIs\fP is a NULL pointer, the
52 .BR mblen ()
53 function
54 .\" The Dinkumware doc and the Single UNIX specification say this, but
55 .\" glibc doesn't implement this.
56 resets the shift state, known to only this function, to the initial state, and
57 returns nonzero if the encoding has nontrivial shift state, or zero if the
58 encoding is stateless.
59 .SH RETURN VALUE
60 The
61 .BR mblen ()
62 function returns the number of
63 bytes parsed from the multibyte
64 sequence starting at \fIs\fP, if a non-null wide character was recognized.
65 It returns 0, if a null wide character was recognized.
66 It returns \-1, if an
67 invalid multibyte sequence was encountered or if it couldn't parse a complete
68 multibyte character.
69 .SH CONFORMING TO
70 C99.
71 .SH NOTES
72 The behavior of
73 .BR mblen ()
74 depends on the
75 .B LC_CTYPE
76 category of the
77 current locale.
78 .PP
79 The function
80 .BR mbrlen (3)
81 provides a better interface to the same
82 functionality.
83 .SH SEE ALSO
84 .BR mbrlen (3)