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