2 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
4 .\" SPDX-License-Identifier: GPL-2.0-or-later
6 .\" References consulted:
7 .\" GNU glibc-2 source code and manual
8 .\" Dinkumware C library reference http://www.dinkumware.com/
9 .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
12 .TH mbtowc 3 (date) "Linux man-pages (unreleased)"
14 mbtowc \- convert a multibyte sequence to a wide character
17 .RI ( libc ", " \-lc )
20 .B #include <stdlib.h>
22 .BI "int mbtowc(wchar_t *restrict " pwc ", const char " s "[restrict ." n "], \
26 The main case for this function is when
34 function inspects at most
36 bytes of the multibyte string starting at
38 extracts the next complete
39 multibyte character, converts it to a wide character and stores it at
41 It updates an internal shift state known only to the
46 does not point to a null byte (\[aq]\e0\[aq]), it returns the number
47 of bytes that were consumed from
49 otherwise it returns 0.
55 do not contain a complete multibyte
56 character, or if they contain an invalid multibyte sequence,
59 This can happen even if
63 if the multibyte string contains redundant shift sequences.
65 A different case is when
72 function behaves as above, except that it does not
73 store the converted wide character in memory.
87 .\" The Dinkumware doc and the Single UNIX specification say this, but
88 .\" glibc doesn't implement this.
89 resets the shift state, only known to this function,
90 to the initial state, and
91 returns nonzero if the encoding has nontrivial shift state, or zero if the
92 encoding is stateless.
98 function returns the number of
99 consumed bytes starting at
103 points to a null byte,
111 returns nonzero if the encoding
112 has nontrivial shift state, or zero if the encoding is stateless.
114 For an explanation of the terms used in this section, see
120 Interface Attribute Value
125 T} Thread safety MT-Unsafe race
128 This function is not multithread safe.
132 a better interface to the same functionality.