]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) Bruno Haible <haible@clisp.cons.org> |
2 | .\" | |
89e3ffe9 | 3 | .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA) |
fea681da MK |
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. | |
fe382ebf | 8 | .\" %%%LICENSE_END |
fea681da MK |
9 | .\" |
10 | .\" References consulted: | |
11 | .\" GNU glibc-2 source code and manual | |
12 | .\" Dinkumware C library reference http://www.dinkumware.com/ | |
008f1ecc | 13 | .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html |
fea681da MK |
14 | .\" ISO/IEC 9899:1999 |
15 | .\" | |
460495ca | 16 | .TH MBLEN 3 2015-08-08 "GNU" "Linux Programmer's Manual" |
fea681da MK |
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 | |
35cfd378 MK |
26 | If |
27 | .I s | |
b437fdd9 | 28 | is not NULL, the |
60a90ecd MK |
29 | .BR mblen () |
30 | function inspects at most | |
35cfd378 MK |
31 | .I n |
32 | bytes of the multibyte string starting at | |
33 | .I s | |
34 | and extracts the | |
c13182ef | 35 | next complete multibyte character. |
33a0ccb2 | 36 | It uses a static anonymous shift state known only to the |
d7ba51f9 MK |
37 | .BR mblen () |
38 | function. | |
c13182ef | 39 | If the multibyte character is not the null wide |
35cfd378 MK |
40 | character, it returns the number of bytes that were consumed from |
41 | .IR s . | |
c13182ef | 42 | If the multibyte character is the null wide character, it returns 0. |
fea681da | 43 | .PP |
35cfd378 | 44 | If the |
51700fd7 | 45 | .IR n |
35cfd378 MK |
46 | bytes starting at |
47 | .I s | |
48 | do not contain a complete multibyte | |
60a90ecd MK |
49 | character, |
50 | .BR mblen () | |
51 | returns \-1. | |
c13182ef | 52 | This can happen even if |
35cfd378 MK |
53 | .I n |
54 | is greater than or equal to | |
55 | .IR MB_CUR_MAX , | |
d7ba51f9 | 56 | if the multibyte string contains redundant shift sequences. |
fea681da | 57 | .PP |
35cfd378 MK |
58 | If the multibyte string starting at |
59 | .I s | |
60 | contains an invalid multibyte | |
60a90ecd MK |
61 | sequence before the next complete character, |
62 | .BR mblen () | |
00e28710 | 63 | also returns \-1. |
fea681da | 64 | .PP |
35cfd378 MK |
65 | If |
66 | .I s | |
b437fdd9 | 67 | is NULL, the |
60a90ecd MK |
68 | .BR mblen () |
69 | function | |
008f1ecc | 70 | .\" The Dinkumware doc and the Single UNIX specification say this, but |
fea681da | 71 | .\" glibc doesn't implement this. |
33a0ccb2 | 72 | resets the shift state, known to only this function, to the initial state, and |
c7094399 | 73 | returns nonzero if the encoding has nontrivial shift state, or zero if the |
fea681da | 74 | encoding is stateless. |
47297adb | 75 | .SH RETURN VALUE |
60a90ecd MK |
76 | The |
77 | .BR mblen () | |
78 | function returns the number of | |
c13182ef | 79 | bytes parsed from the multibyte |
35cfd378 MK |
80 | sequence starting at |
81 | .IR s , | |
82 | if a non-null wide character was recognized. | |
c13182ef MK |
83 | It returns 0, if a null wide character was recognized. |
84 | It returns \-1, if an | |
fea681da MK |
85 | invalid multibyte sequence was encountered or if it couldn't parse a complete |
86 | multibyte character. | |
de541d4b | 87 | .SH ATTRIBUTES |
d355517b PH |
88 | For an explanation of the terms used in this section, see |
89 | .BR attributes (7). | |
90 | .TS | |
91 | allbox; | |
92 | lb lb lb | |
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 |
47297adb | 99 | .SH CONFORMING TO |
c2200cab | 100 | POSIX.1-2001, POSIX.1-2008, C99. |
fea681da | 101 | .SH NOTES |
d9bfdb9c | 102 | The behavior of |
60a90ecd | 103 | .BR mblen () |
1274071a MK |
104 | depends on the |
105 | .B LC_CTYPE | |
106 | category of the | |
fea681da MK |
107 | current locale. |
108 | .PP | |
60a90ecd MK |
109 | The function |
110 | .BR mbrlen (3) | |
111 | provides a better interface to the same | |
fea681da | 112 | functionality. |
47297adb | 113 | .SH SEE ALSO |
e37e3282 | 114 | .BR mbrlen (3) |