1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
3 .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
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.
10 .\" References consulted:
11 .\" GNU glibc-2 source code and manual
12 .\" Dinkumware C library reference http://www.dinkumware.com/
13 .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
16 .TH WCRTOMB 3 2021-03-22 "GNU" "Linux Programmer's Manual"
18 wcrtomb \- convert a wide character to a multibyte sequence
23 .BI "size_t wcrtomb(char *restrict " s ", wchar_t " wc \
24 ", mbstate_t *restrict " ps );
27 The main case for this function is when
32 is not a null wide character (L\(aq\e0\(aq).
36 converts the wide character
38 to its multibyte representation and stores it
39 at the beginning of the character
42 It updates the shift state
45 returns the length of said multibyte representation,
46 that is, the number of bytes
50 A different case is when
55 is a null wide character (L\(aq\e0\(aq).
59 the character array pointed to by
61 the shift sequence needed to
64 back to the initial state,
65 followed by a \(aq\e0\(aq byte.
66 It updates the shift state
69 it into the initial state),
70 and returns the length of the shift sequence plus
71 one, that is, the number of bytes written at
80 and the function effectively returns
82 wcrtomb(buf, L\(aq\e0\(aq, ps)
86 is an internal anonymous buffer.
88 In all of the above cases, if
90 is NULL, a static anonymous
91 state known only to the
93 function is used instead.
97 function returns the number of
98 bytes that have been or would
99 have been written to the byte array at
104 represented as a multibyte sequence (according to the current locale),
111 For an explanation of the terms used in this section, see
119 Interface Attribute Value
122 T} Thread safety MT-Unsafe race:wcrtomb/!ps
128 POSIX.1-2001, POSIX.1-2008, C99.
139 is not multithread safe.