]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/wcstombs.3
Removed trailing white space at end of lines
[thirdparty/man-pages.git] / man3 / wcstombs.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
89e3ffe9 3.\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
fea681da
MK
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.
fe382ebf 8.\" %%%LICENSE_END
fea681da
MK
9.\"
10.\" References consulted:
11.\" GNU glibc-2 source code and manual
12.\" Dinkumware C library reference http://www.dinkumware.com/
008f1ecc 13.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
fea681da
MK
14.\" ISO/IEC 9899:1999
15.\"
3c81e148 16.TH WCSTOMBS 3 2011-10-16 "GNU" "Linux Programmer's Manual"
fea681da 17.SH NAME
d0f17b57 18wcstombs \- convert a wide-character string to a multibyte string
fea681da
MK
19.SH SYNOPSIS
20.nf
21.B #include <stdlib.h>
22.sp
23.BI "size_t wcstombs(char *" dest ", const wchar_t *" src ", size_t " n );
24.fi
25.SH DESCRIPTION
40aa0db0
MK
26If
27.I dest
28is not a NULL pointer, the
60a90ecd
MK
29.BR wcstombs ()
30function converts
40aa0db0
MK
31the wide-character string
32.I src
33to a multibyte string starting at
34.IR dest .
35At most
36.I n
37bytes are written to
38.IR dest .
c13182ef
MK
39The conversion
40starts in the initial state.
41The conversion can stop for three reasons:
fea681da
MK
42.PP
431. A wide character has been encountered that can not be represented as a
c13182ef
MK
44multibyte sequence (according to the current locale).
45In this case
009df872 46.I (size_t)\ \-1
7d2cb9d5 47is returned.
fea681da 48.PP
c13182ef
MK
492. The length limit forces a stop.
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.
fea681da
MK
53.PP
543. The wide-character string has been completely converted, including the
e9c23bc6 55terminating null wide character (L\(aq\\0\(aq).
c13182ef 56In this case the conversion ends in the initial state.
40aa0db0
MK
57The number of bytes written to
58.IR dest ,
3c81e148 59excluding the terminating null byte (\(aq\\0\(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
51700fd7 68.IR dest
40aa0db0
MK
69is NULL,
70.I n
71is ignored, and the conversion proceeds as
fb186734
MK
72above, except that the converted bytes are not written out to memory,
73and that 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
77is greater or equal to
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
fea681da 83converted part of multibyte sequence, not including the terminating null byte.
fb186734 84If a wide character was encountered which could not be
7d2cb9d5 85converted,
009df872 86.I (size_t)\ \-1
7d2cb9d5 87is returned.
47297adb 88.SH CONFORMING TO
68e1685c 89C99.
fea681da 90.SH NOTES
d9bfdb9c 91The behavior of
60a90ecd 92.BR wcstombs ()
1274071a
MK
93depends on the
94.B LC_CTYPE
95category of the
fea681da
MK
96current locale.
97.PP
60a90ecd
MK
98The function
99.BR wcsrtombs (3)
100provides a thread safe interface to
91fe9d5c 101the same functionality.
47297adb 102.SH SEE ALSO
49438ab7 103.BR mbstowcs (3),
e37e3282 104.BR wcsrtombs (3)