]>
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 mbrlen 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
13 | .SH NAME |
14 | mbrlen \- determine number of bytes in next multibyte character | |
3391a6d6 AC |
15 | .SH LIBRARY |
16 | Standard C library | |
8fc3b2cf | 17 | .RI ( libc ", " \-lc ) |
fea681da MK |
18 | .SH SYNOPSIS |
19 | .nf | |
20 | .B #include <wchar.h> | |
68e4db0a | 21 | .PP |
1eed67e7 | 22 | .BI "size_t mbrlen(const char " s "[restrict ." n "], size_t " n , |
95bc7a76 | 23 | .BI " mbstate_t *restrict " ps ); |
fea681da MK |
24 | .fi |
25 | .SH DESCRIPTION | |
60a90ecd MK |
26 | The |
27 | .BR mbrlen () | |
35cfd378 MK |
28 | function inspects at most |
29 | .I n | |
30 | bytes of the multibyte | |
31 | string starting at | |
32 | .I s | |
33 | and extracts the next complete multibyte character. | |
34 | It updates the shift state | |
35 | .IR *ps . | |
c13182ef | 36 | If the multibyte character is not the |
fea681da | 37 | null wide character, it returns the number of bytes that were consumed from |
35cfd378 | 38 | .IR s . |
c13182ef | 39 | If the multibyte character is the null wide character, it resets the |
35cfd378 MK |
40 | shift state |
41 | .I *ps | |
42 | to the initial state and returns 0. | |
fea681da | 43 | .PP |
35cfd378 | 44 | If the |
1ae6b2c7 | 45 | .I n |
35cfd378 MK |
46 | bytes starting at |
47 | .I s | |
48 | do not contain a complete multibyte | |
60a90ecd MK |
49 | character, |
50 | .BR mbrlen () | |
35cfd378 MK |
51 | returns |
52 | .IR "(size_t)\ \-2" . | |
c13182ef | 53 | This can happen even if |
35cfd378 MK |
54 | .I n |
55 | >= | |
56 | .IR MB_CUR_MAX , | |
57 | if the multibyte string contains redundant shift | |
fea681da MK |
58 | sequences. |
59 | .PP | |
35cfd378 MK |
60 | If the multibyte string starting at |
61 | .I s | |
62 | contains an invalid multibyte | |
60a90ecd MK |
63 | sequence before the next complete character, |
64 | .BR mbrlen () | |
65 | returns | |
1ae6b2c7 | 66 | .I (size_t)\ \-1 |
35cfd378 MK |
67 | and sets |
68 | .I errno | |
69 | to | |
70 | .BR EILSEQ . | |
c13182ef | 71 | In this case, |
35cfd378 MK |
72 | the effects on |
73 | .I *ps | |
74 | are undefined. | |
fea681da | 75 | .PP |
35cfd378 MK |
76 | If |
77 | .I ps | |
b437fdd9 | 78 | is NULL, a static anonymous state known only to the |
d9a10d9d MK |
79 | .BR mbrlen () |
80 | function is used instead. | |
47297adb | 81 | .SH RETURN VALUE |
60a90ecd MK |
82 | The |
83 | .BR mbrlen () | |
84 | function returns the number of bytes | |
c13182ef | 85 | parsed from the multibyte |
35cfd378 MK |
86 | sequence starting at |
87 | .IR s , | |
88 | if a non-null wide character was recognized. | |
c13182ef | 89 | It returns 0, if a null wide character was recognized. |
7d2cb9d5 | 90 | It returns |
009df872 | 91 | .I "(size_t)\ \-1" |
35cfd378 MK |
92 | and sets |
93 | .I errno | |
94 | to | |
95 | .BR EILSEQ , | |
96 | if an invalid multibyte sequence was | |
c13182ef | 97 | encountered. |
35cfd378 | 98 | It returns |
1ae6b2c7 | 99 | .I (size_t)\ \-2 |
35cfd378 MK |
100 | if it couldn't parse a complete multibyte |
101 | character, meaning that | |
102 | .I n | |
103 | should be increased. | |
6c2ec40d | 104 | .SH ATTRIBUTES |
fd35a2c6 PH |
105 | For an explanation of the terms used in this section, see |
106 | .BR attributes (7). | |
107 | .TS | |
108 | allbox; | |
c466875e | 109 | lbx lb lb |
fd35a2c6 PH |
110 | l l l. |
111 | Interface Attribute Value | |
112 | T{ | |
9e54434e BR |
113 | .na |
114 | .nh | |
6c2ec40d | 115 | .BR mbrlen () |
fd35a2c6 PH |
116 | T} Thread safety MT-Unsafe race:mbrlen/!ps |
117 | .TE | |
c466875e | 118 | .sp 1 |
3113c7f3 | 119 | .SH STANDARDS |
4131356c AC |
120 | C11, POSIX.1-2008. |
121 | .SH HISTORY | |
122 | POSIX.1-2001, C99. | |
fea681da | 123 | .SH NOTES |
d9bfdb9c | 124 | The behavior of |
60a90ecd | 125 | .BR mbrlen () |
1274071a MK |
126 | depends on the |
127 | .B LC_CTYPE | |
128 | category of the | |
fea681da | 129 | current locale. |
47297adb | 130 | .SH SEE ALSO |
e37e3282 | 131 | .BR mbrtowc (3) |