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 2016-10-08 "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 *" dest ", const wchar_t *" src ", size_t " n );
31 the wide-character string
33 to a multibyte string starting at
39 The sequence of characters placed in
41 begins in the initial shift state.
42 The conversion can stop for three reasons:
44 A wide character has been encountered that can not be represented as a
45 multibyte sequence (according to the current locale).
50 The length limit forces a stop.
51 In this case, the number of bytes written to
53 is returned, but the shift state at this point is lost.
55 The wide-character string has been completely converted, including the
56 terminating null wide character (L\(aq\\0\(aq).
57 In this case, the conversion ends in the initial shift state.
58 The number of bytes written to
60 excluding the terminating null byte (\(aq\\0\(aq), is returned.
62 The programmer must ensure that there is room for at least
72 is ignored, and the conversion proceeds as
73 above, except that the converted bytes are not written out to memory,
74 and no length limit exists.
76 In order to avoid the case 2 above, the programmer should make sure
78 is greater than or equal to
79 .IR "wcstombs(NULL,src,0)+1" .
83 function returns the number of bytes that make up the
84 converted part of a multibyte sequence,
85 not including the terminating null byte.
86 If a wide character was encountered which could not be
91 For an explanation of the terms used in this section, see
97 Interface Attribute Value
100 T} Thread safety MT-Safe
104 POSIX.1-2001, POSIX.1-2008, C99.
115 provides a better interface to the same functionality.