OSDN Git Service

LDP: Update original to LDP v3.79
[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  2013-06-21 "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
27 .I s
28 is not NULL, the
29 .BR mblen ()
30 function inspects at most
31 .I n
32 bytes of the multibyte string starting at
33 .I s
34 and extracts the
35 next complete multibyte character.
36 It uses a static anonymous shift state known only to the
37 .BR mblen ()
38 function.
39 If the multibyte character is not the null wide
40 character, it returns the number of bytes that were consumed from
41 .IR s .
42 If the multibyte character is the null wide character, it returns 0.
43 .PP
44 If the
45 .IR n
46 bytes starting at
47 .I s
48 do not contain a complete multibyte
49 character,
50 .BR mblen ()
51 returns \-1.
52 This can happen even if
53 .I n
54 is greater than or equal to
55 .IR MB_CUR_MAX ,
56 if the multibyte string contains redundant shift sequences.
57 .PP
58 If the multibyte string starting at
59 .I s
60 contains an invalid multibyte
61 sequence before the next complete character,
62 .BR mblen ()
63 also returns \-1.
64 .PP
65 If
66 .I s
67 is NULL, the
68 .BR mblen ()
69 function
70 .\" The Dinkumware doc and the Single UNIX specification say this, but
71 .\" glibc doesn't implement this.
72 resets the shift state, known to only this function, to the initial state, and
73 returns nonzero if the encoding has nontrivial shift state, or zero if the
74 encoding is stateless.
75 .SH RETURN VALUE
76 The
77 .BR mblen ()
78 function returns the number of
79 bytes parsed from the multibyte
80 sequence starting at
81 .IR s ,
82 if a non-null wide character was recognized.
83 It returns 0, if a null wide character was recognized.
84 It returns \-1, if an
85 invalid multibyte sequence was encountered or if it couldn't parse a complete
86 multibyte character.
87 .SH ATTRIBUTES
88 .SS Multithreading (see pthreads(7))
89 The
90 .BR mblen ()
91 function is not thread-safe.
92 .SH CONFORMING TO
93 C99.
94 .SH NOTES
95 The behavior of
96 .BR mblen ()
97 depends on the
98 .B LC_CTYPE
99 category of the
100 current locale.
101 .PP
102 The function
103 .BR mbrlen (3)
104 provides a better interface to the same
105 functionality.
106 .SH SEE ALSO
107 .BR mbrlen (3)
108 .SH COLOPHON
109 This page is part of release 3.79 of the Linux
110 .I man-pages
111 project.
112 A description of the project,
113 information about reporting bugs,
114 and the latest version of this page,
115 can be found at
116 \%http://www.kernel.org/doc/man\-pages/.