]>
Commit | Line | Data |
---|---|---|
a1eaacb1 | 1 | '\" t |
fea681da MK |
2 | .\" Copyright (c) Bruno Haible <haible@clisp.cons.org> |
3 | .\" | |
e4a74ca8 | 4 | .\" SPDX-License-Identifier: GPL-2.0-or-later |
fea681da MK |
5 | .\" |
6 | .\" References consulted: | |
7 | .\" GNU glibc-2 source code and manual | |
8 | .\" Dinkumware C library reference http://www.dinkumware.com/ | |
008f1ecc | 9 | .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html |
fea681da MK |
10 | .\" ISO/IEC 9899:1999 |
11 | .\" | |
4c1c5274 | 12 | .TH mblen 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
13 | .SH NAME |
14 | mblen \- determine number of bytes in next multibyte character | |
e725fd6e AC |
15 | .SH LIBRARY |
16 | Standard C library | |
8fc3b2cf | 17 | .RI ( libc ", " \-lc ) |
fea681da MK |
18 | .SH SYNOPSIS |
19 | .nf | |
20 | .B #include <stdlib.h> | |
68e4db0a | 21 | .PP |
1eed67e7 | 22 | .BI "int mblen(const char " s [. n "], size_t " n ); |
fea681da MK |
23 | .fi |
24 | .SH DESCRIPTION | |
35cfd378 MK |
25 | If |
26 | .I s | |
b437fdd9 | 27 | is not NULL, the |
60a90ecd MK |
28 | .BR mblen () |
29 | function inspects at most | |
35cfd378 MK |
30 | .I n |
31 | bytes of the multibyte string starting at | |
32 | .I s | |
33 | and extracts the | |
c13182ef | 34 | next complete multibyte character. |
33a0ccb2 | 35 | It uses a static anonymous shift state known only to the |
d7ba51f9 MK |
36 | .BR mblen () |
37 | function. | |
c13182ef | 38 | If the multibyte character is not the null wide |
35cfd378 MK |
39 | character, it returns the number of bytes that were consumed from |
40 | .IR s . | |
c13182ef | 41 | If the multibyte character is the null wide character, it returns 0. |
fea681da | 42 | .PP |
35cfd378 | 43 | If the |
1ae6b2c7 | 44 | .I n |
35cfd378 MK |
45 | bytes starting at |
46 | .I s | |
47 | do not contain a complete multibyte | |
60a90ecd MK |
48 | character, |
49 | .BR mblen () | |
50 | returns \-1. | |
c13182ef | 51 | This can happen even if |
35cfd378 MK |
52 | .I n |
53 | is greater than or equal to | |
54 | .IR MB_CUR_MAX , | |
d7ba51f9 | 55 | if the multibyte string contains redundant shift sequences. |
fea681da | 56 | .PP |
35cfd378 MK |
57 | If the multibyte string starting at |
58 | .I s | |
59 | contains an invalid multibyte | |
60a90ecd MK |
60 | sequence before the next complete character, |
61 | .BR mblen () | |
00e28710 | 62 | also returns \-1. |
fea681da | 63 | .PP |
35cfd378 MK |
64 | If |
65 | .I s | |
b437fdd9 | 66 | is NULL, the |
60a90ecd MK |
67 | .BR mblen () |
68 | function | |
008f1ecc | 69 | .\" The Dinkumware doc and the Single UNIX specification say this, but |
fea681da | 70 | .\" glibc doesn't implement this. |
33a0ccb2 | 71 | resets the shift state, known to only this function, to the initial state, and |
c7094399 | 72 | returns nonzero if the encoding has nontrivial shift state, or zero if the |
fea681da | 73 | encoding is stateless. |
47297adb | 74 | .SH RETURN VALUE |
60a90ecd MK |
75 | The |
76 | .BR mblen () | |
77 | function returns the number of | |
c13182ef | 78 | bytes parsed from the multibyte |
35cfd378 MK |
79 | sequence starting at |
80 | .IR s , | |
81 | if a non-null wide character was recognized. | |
c13182ef MK |
82 | It returns 0, if a null wide character was recognized. |
83 | It returns \-1, if an | |
fea681da MK |
84 | invalid multibyte sequence was encountered or if it couldn't parse a complete |
85 | multibyte character. | |
de541d4b | 86 | .SH ATTRIBUTES |
d355517b PH |
87 | For an explanation of the terms used in this section, see |
88 | .BR attributes (7). | |
89 | .TS | |
90 | allbox; | |
c466875e | 91 | lbx lb lb |
d355517b PH |
92 | l l l. |
93 | Interface Attribute Value | |
94 | T{ | |
9e54434e BR |
95 | .na |
96 | .nh | |
de541d4b | 97 | .BR mblen () |
ae47f91a | 98 | T} Thread safety MT-Unsafe race |
d355517b | 99 | .TE |
c466875e | 100 | .sp 1 |
4131356c AC |
101 | .SH VERSIONS |
102 | The function | |
103 | .BR mbrlen (3) | |
104 | provides a better interface to the same | |
105 | functionality. | |
3113c7f3 | 106 | .SH STANDARDS |
4131356c AC |
107 | C11, POSIX.1-2008. |
108 | .SH HISTORY | |
109 | POSIX.1-2001, C99. | |
fea681da | 110 | .SH NOTES |
d9bfdb9c | 111 | The behavior of |
60a90ecd | 112 | .BR mblen () |
1274071a MK |
113 | depends on the |
114 | .B LC_CTYPE | |
115 | category of the | |
fea681da | 116 | current locale. |
47297adb | 117 | .SH SEE ALSO |
e37e3282 | 118 | .BR mbrlen (3) |