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 WCSTOMBS 3 2021-03-22 "GNU" "Linux Programmer's Manual"
18 wcstombs \- convert a wide-character string to a multibyte string
21 .B #include <stdlib.h>
23 .BI "size_t wcstombs(char *restrict " dest ", const wchar_t *restrict " src ,
32 the wide-character string
34 to a multibyte string starting at
40 The sequence of characters placed in
42 begins in the initial shift state.
43 The conversion can stop for three reasons:
45 A wide character has been encountered that can not be represented as a
46 multibyte sequence (according to the current locale).
51 The length limit forces a stop.
52 In this case, the number of bytes written to
54 is returned, but the shift state at this point is lost.
56 The wide-character string has been completely converted, including the
57 terminating null wide character (L\(aq\e0\(aq).
58 In this case, the conversion ends in the initial shift state.
59 The number of bytes written to
61 excluding the terminating null byte (\(aq\e0\(aq), is returned.
63 The programmer must ensure that there is room for at least
73 is ignored, and the conversion proceeds as
74 above, except that the converted bytes are not written out to memory,
75 and no length limit exists.
77 In order to avoid the case 2 above, the programmer should make sure
79 is greater than or equal to
80 .IR "wcstombs(NULL,src,0)+1" .
84 function returns the number of bytes that make up the
85 converted part of a multibyte sequence,
86 not including the terminating null byte.
87 If a wide character was encountered which could not be
92 For an explanation of the terms used in this section, see
100 Interface Attribute Value
103 T} Thread safety MT-Safe
109 POSIX.1-2001, POSIX.1-2008, C99.
120 provides a better interface to the same functionality.