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