1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
3 .\" SPDX-License-Identifier: GPL-2.0-or-later
5 .\" References consulted:
6 .\" GNU glibc-2 source code and manual
7 .\" Dinkumware C library reference http://www.dinkumware.com/
8 .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
11 .TH MBTOWC 3 2021-03-22 "GNU" "Linux Programmer's Manual"
13 mbtowc \- convert a multibyte sequence to a wide character
16 .RI ( libc ", " \-lc )
19 .B #include <stdlib.h>
21 .BI "int mbtowc(wchar_t *restrict " pwc ", const char *restrict " s \
25 The main case for this function is when
33 function inspects at most
35 bytes of the multibyte string starting at
37 extracts the next complete
38 multibyte character, converts it to a wide character and stores it at
40 It updates an internal shift state known only to the
45 does not point to a null byte (\(aq\e0\(aq), it returns the number
46 of bytes that were consumed from
48 otherwise it returns 0.
54 do not contain a complete multibyte
55 character, or if they contain an invalid multibyte sequence,
58 This can happen even if
62 if the multibyte string contains redundant shift sequences.
64 A different case is when
71 function behaves as above, except that it does not
72 store the converted wide character in memory.
86 .\" The Dinkumware doc and the Single UNIX specification say this, but
87 .\" glibc doesn't implement this.
88 resets the shift state, only known to this function,
89 to the initial state, and
90 returns nonzero if the encoding has nontrivial shift state, or zero if the
91 encoding is stateless.
97 function returns the number of
98 consumed bytes starting at
102 points to a null byte,
110 returns nonzero if the encoding
111 has nontrivial shift state, or zero if the encoding is stateless.
113 For an explanation of the terms used in this section, see
121 Interface Attribute Value
124 T} Thread safety MT-Unsafe race
130 POSIX.1-2001, POSIX.1-2008, C99.
139 This function is not multithread safe.
143 a better interface to the same functionality.