]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/wctomb.3
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man3 / wctomb.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 wctomb 3 (date) "Linux man-pages (unreleased)"
fea681da
MK
12.SH NAME
13wctomb \- convert a wide character to a multibyte sequence
f3cdb40a
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
fea681da
MK
21.BI "int wctomb(char *" s ", wchar_t " wc );
22.fi
23.SH DESCRIPTION
35cfd378
MK
24If
25.I s
26is not NULL,
60a90ecd
MK
27the
28.BR wctomb ()
29function converts the wide character
35cfd378
MK
30.I wc
31to its multibyte representation and stores it at the beginning of
32the character array pointed to by
33.IR s .
c13182ef
MK
34It updates the shift state, which
35is stored in a static anonymous variable
33a0ccb2 36known only to the
8c917f5c
MK
37.BR wctomb ()
38function,
c13182ef 39and returns the length of said multibyte representation,
75b94dc3 40that is, the number of
35cfd378
MK
41bytes written at
42.IR s .
fea681da 43.PP
c13182ef 44The programmer must ensure that there is
35cfd378
MK
45room for at least
46.B MB_CUR_MAX
47bytes at
48.IR s .
fea681da 49.PP
35cfd378
MK
50If
51.I s
52is NULL, the
60a90ecd
MK
53.BR wctomb ()
54function
008f1ecc 55.\" The Dinkumware doc and the Single UNIX specification say this, but
fea681da 56.\" glibc doesn't implement this.
33a0ccb2 57resets the shift state, known only to this function,
c13182ef 58to the initial state, and
c7094399 59returns nonzero if the encoding has nontrivial shift state,
c13182ef 60or zero if the encoding is stateless.
47297adb 61.SH RETURN VALUE
35cfd378
MK
62If
63.I s
64is not NULL, the
60a90ecd
MK
65.BR wctomb ()
66function
c13182ef 67returns the number of bytes
35cfd378
MK
68that have been written to the byte array at
69.IR s .
70If
71.I wc
72can not be
c13182ef
MK
73represented as a multibyte sequence (according
74to the current locale), \-1 is returned.
fea681da 75.PP
35cfd378
MK
76If
77.I s
78is NULL, the
60a90ecd 79.BR wctomb ()
c7094399 80function returns nonzero if the
c382a365 81encoding has nontrivial shift state, or zero if the encoding is stateless.
69e8f02f 82.SH ATTRIBUTES
bcd70a87
PH
83For an explanation of the terms used in this section, see
84.BR attributes (7).
c466875e
MK
85.ad l
86.nh
bcd70a87
PH
87.TS
88allbox;
c466875e 89lbx lb lb
bcd70a87
PH
90l l l.
91Interface Attribute Value
92T{
69e8f02f 93.BR wctomb ()
8ff1e928 94T} Thread safety MT-Unsafe race
bcd70a87 95.TE
c466875e
MK
96.hy
97.ad
98.sp 1
3113c7f3 99.SH STANDARDS
f6221652 100POSIX.1-2001, POSIX.1-2008, C99.
fea681da 101.SH NOTES
d9bfdb9c 102The behavior of
60a90ecd 103.BR wctomb ()
1274071a
MK
104depends on the
105.B LC_CTYPE
106category of the
fea681da
MK
107current locale.
108.PP
60a90ecd
MK
109The function
110.BR wcrtomb (3)
111provides
fea681da 112a better interface to the same functionality.
47297adb 113.SH SEE ALSO
e37e3282 114.BR MB_CUR_MAX (3),
4670051b
MK
115.BR mblen (3),
116.BR mbstowcs (3),
117.BR mbtowc (3),
e37e3282
MK
118.BR wcrtomb (3),
119.BR wcstombs (3)