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