]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/wcstombs.3
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man3 / wcstombs.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
e4a74ca8 3.\" SPDX-License-Identifier: GPL-2.0-or-later
fea681da
MK
4.\"
5.\" References consulted:
6.\" GNU glibc-2 source code and manual
7.\" Dinkumware C library reference http://www.dinkumware.com/
008f1ecc 8.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
fea681da
MK
9.\" ISO/IEC 9899:1999
10.\"
4c1c5274 11.TH wcstombs 3 (date) "Linux man-pages (unreleased)"
fea681da 12.SH NAME
d0f17b57 13wcstombs \- convert a wide-character string to a multibyte string
cd8b08b0
AC
14.SH LIBRARY
15Standard C library
8fc3b2cf 16.RI ( libc ", " \-lc )
fea681da
MK
17.SH SYNOPSIS
18.nf
19.B #include <stdlib.h>
68e4db0a 20.PP
7ce7d2ad
AC
21.BI "size_t wcstombs(char *restrict " dest ", const wchar_t *restrict " src ,
22.BI " size_t " n );
fea681da
MK
23.fi
24.SH DESCRIPTION
40aa0db0
MK
25If
26.I dest
b437fdd9 27is not NULL, the
60a90ecd
MK
28.BR wcstombs ()
29function converts
40aa0db0
MK
30the wide-character string
31.I src
32to a multibyte string starting at
33.IR dest .
34At most
35.I n
36bytes are written to
37.IR dest .
3942b6bc 38The sequence of characters placed in
1ae6b2c7 39.I dest
3942b6bc 40begins in the initial shift state.
c13182ef 41The conversion can stop for three reasons:
22356d97 42.IP \(bu 3
db59590e 43A wide character has been encountered that can not be represented as a
c13182ef 44multibyte sequence (according to the current locale).
9218ef3d 45In this case,
009df872 46.I (size_t)\ \-1
7d2cb9d5 47is returned.
22356d97 48.IP \(bu
db59590e 49The length limit forces a stop.
441efbb7 50In this case, the number of bytes written to
40aa0db0
MK
51.I dest
52is returned, but the shift state at this point is lost.
22356d97 53.IP \(bu
db59590e 54The wide-character string has been completely converted, including the
d1a71985 55terminating null wide character (L\(aq\e0\(aq).
3942b6bc 56In this case, the conversion ends in the initial shift state.
40aa0db0
MK
57The number of bytes written to
58.IR dest ,
d1a71985 59excluding the terminating null byte (\(aq\e0\(aq), is returned.
fea681da 60.PP
40aa0db0
MK
61The programmer must ensure that there is room for at least
62.I n
63bytes
64at
65.IR dest .
fea681da 66.PP
40aa0db0 67If
1ae6b2c7 68.I dest
40aa0db0
MK
69is NULL,
70.I n
71is ignored, and the conversion proceeds as
fb186734 72above, except that the converted bytes are not written out to memory,
d75efe73 73and no length limit exists.
fea681da 74.PP
40aa0db0
MK
75In order to avoid the case 2 above, the programmer should make sure
76.I n
d75efe73 77is greater than or equal to
40aa0db0 78.IR "wcstombs(NULL,src,0)+1" .
47297adb 79.SH RETURN VALUE
60a90ecd
MK
80The
81.BR wcstombs ()
82function returns the number of bytes that make up the
d75efe73
MK
83converted part of a multibyte sequence,
84not including the terminating null byte.
fb186734 85If a wide character was encountered which could not be
7d2cb9d5 86converted,
009df872 87.I (size_t)\ \-1
7d2cb9d5 88is returned.
b640fcfa
MS
89.SH ATTRIBUTES
90For an explanation of the terms used in this section, see
91.BR attributes (7).
c466875e
MK
92.ad l
93.nh
b640fcfa
MS
94.TS
95allbox;
c466875e 96lbx lb lb
b640fcfa
MS
97l l l.
98Interface Attribute Value
99T{
100.BR wcstombs ()
101T} Thread safety MT-Safe
102.TE
c466875e
MK
103.hy
104.ad
847e0d88 105.sp 1
3113c7f3 106.SH STANDARDS
6d2e3caf 107POSIX.1-2001, POSIX.1-2008, C99.
fea681da 108.SH NOTES
d9bfdb9c 109The behavior of
60a90ecd 110.BR wcstombs ()
1274071a
MK
111depends on the
112.B LC_CTYPE
113category of the
fea681da
MK
114current locale.
115.PP
60a90ecd
MK
116The function
117.BR wcsrtombs (3)
fdcc06ee 118provides a better interface to the same functionality.
47297adb 119.SH SEE ALSO
4670051b 120.BR mblen (3),
49438ab7 121.BR mbstowcs (3),
ca38b869 122.BR mbtowc (3),
bba4bbbd 123.BR wcsrtombs (3),
e8b81d34 124.BR wctomb (3)