]>
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 MBRLEN 3 2015-08-08 "GNU" "Linux Programmer's Manual" |
fea681da MK |
17 | .SH NAME |
18 | mbrlen \- determine number of bytes in next multibyte character | |
19 | .SH SYNOPSIS | |
20 | .nf | |
21 | .B #include <wchar.h> | |
68e4db0a | 22 | .PP |
fea681da MK |
23 | .BI "size_t mbrlen(const char *" s ", size_t " n ", mbstate_t *" ps ); |
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 |
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 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 | |
35cfd378 MK |
66 | .IR "(size_t)\ \-1" |
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 MK |
98 | It returns |
99 | .IR "(size_t)\ \-2" | |
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; | |
109 | lb lb lb | |
110 | l l l. | |
111 | Interface Attribute Value | |
112 | T{ | |
6c2ec40d | 113 | .BR mbrlen () |
fd35a2c6 PH |
114 | T} Thread safety MT-Unsafe race:mbrlen/!ps |
115 | .TE | |
47297adb | 116 | .SH CONFORMING TO |
5f11381b | 117 | POSIX.1-2001, POSIX.1-2008, C99. |
fea681da | 118 | .SH NOTES |
d9bfdb9c | 119 | The behavior of |
60a90ecd | 120 | .BR mbrlen () |
1274071a MK |
121 | depends on the |
122 | .B LC_CTYPE | |
123 | category of the | |
fea681da | 124 | current locale. |
47297adb | 125 | .SH SEE ALSO |
e37e3282 | 126 | .BR mbrtowc (3) |