]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/wcstombs.3
Manual fixes of parentheses formatting
[thirdparty/man-pages.git] / man3 / wcstombs.3
1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" References consulted:
9 .\" GNU glibc-2 source code and manual
10 .\" Dinkumware C library reference http://www.dinkumware.com/
11 .\" OpenGroup's Single Unix specification http://www.UNIX-systems.org/online.html
12 .\" ISO/IEC 9899:1999
13 .\"
14 .TH WCSTOMBS 3 1999-07-25 "GNU" "Linux Programmer's Manual"
15 .SH NAME
16 wcstombs \- convert a wide character string to a multibyte string
17 .SH SYNOPSIS
18 .nf
19 .B #include <stdlib.h>
20 .sp
21 .BI "size_t wcstombs(char *" dest ", const wchar_t *" src ", size_t " n );
22 .fi
23 .SH DESCRIPTION
24 If \fIdest\fP is not a NULL pointer, the \fBwcstombs\fP() function converts
25 the wide-character string \fIsrc\fP to a multibyte string starting at
26 \fIdest\fP. At most \fIn\fP bytes are written to \fIdest\fP. The conversion
27 starts in the initial state. The conversion can stop for three reasons:
28 .PP
29 1. A wide character has been encountered that can not be represented as a
30 multibyte sequence (according to the current locale). In this case
31 (size_t)(\-1) is returned.
32 .PP
33 2. The length limit forces a stop. In this case the number of bytes written to
34 \fIdest\fP is returned, but the shift state at this point is lost.
35 .PP
36 3. The wide-character string has been completely converted, including the
37 terminating L'\\0'. In this case the conversion ends in the initial state.
38 The number of bytes written to \fIdest\fP, excluding the terminating '\\0'
39 byte, is returned.
40 .PP
41 The programmer must ensure that there is room for at least \fIn\fP bytes
42 at \fIdest\fP.
43 .PP
44 If \fIdest\fP is NULL, \fIn\fP is ignored, and the conversion proceeds as
45 above, except that the converted bytes are not written out to memory, and that
46 no length limit exists.
47 .PP
48 In order to avoid the case 2 above, the programmer should make sure \fIn\fP
49 is greater or equal to \fIwcstombs(NULL,src,0)+1\fP.
50 .SH "RETURN VALUE"
51 The \fBwcstombs\fP() function returns the number of bytes that make up the
52 converted part of multibyte sequence, not including the terminating null byte.
53 If a wide character was encountered which could not be converted, (size_t)(\-1)
54 is returned.
55 .SH "CONFORMING TO"
56 ISO/ANSI C, UNIX98
57 .SH "SEE ALSO"
58 .BR wcsrtombs (3)
59 .SH NOTES
60 The behaviour of \fBwcstombs\fP() depends on the LC_CTYPE category of the
61 current locale.
62 .PP
63 The function \fBwcsrtombs\fP() provides a thread safe interface to the same
64 functionality.