]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/wcrtomb.3
splice.2: EAGAIN can occur when called on nonblocking file descriptors
[thirdparty/man-pages.git] / man3 / wcrtomb.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.\"
9ba01802 16.TH WCRTOMB 3 2019-03-06 "GNU" "Linux Programmer's Manual"
fea681da
MK
17.SH NAME
18wcrtomb \- convert a wide character to a multibyte sequence
19.SH SYNOPSIS
20.nf
21.B #include <wchar.h>
68e4db0a 22.PP
fea681da
MK
23.BI "size_t wcrtomb(char *" s ", wchar_t " wc ", mbstate_t *" ps );
24.fi
25.SH DESCRIPTION
e4a0d6cb
MK
26The main case for this function is when
27.I s
28is
29not NULL and
30.I wc
d1a71985 31is not a null wide character (L\(aq\e0\(aq).
60a90ecd
MK
32In this case, the
33.BR wcrtomb ()
34function
e4a0d6cb
MK
35converts the wide character
36.I wc
c13182ef
MK
37to its multibyte representation and stores it
38at the beginning of the character
e4a0d6cb
MK
39array pointed to by
40.IR s .
41It updates the shift state
42.IR *ps ,
43and
c13182ef 44returns the length of said multibyte representation,
75b94dc3 45that is, the number of bytes
e4a0d6cb
MK
46written at
47.IR s .
fea681da 48.PP
e4a0d6cb
MK
49A different case is when
50.I s
51is not NULL,
52but
53.I wc
d1a71985 54is a null wide character (L\(aq\e0\(aq).
09725fbc 55In this case, the
60a90ecd
MK
56.BR wcrtomb ()
57function stores at
c13182ef 58the character array pointed to by
e4a0d6cb
MK
59.I s
60the shift sequence needed to
61bring
62.I *ps
63back to the initial state,
d1a71985 64followed by a \(aq\e0\(aq byte.
e4a0d6cb
MK
65It updates the shift state
66.I *ps
67(i.e., brings
c13182ef
MK
68it into the initial state),
69and returns the length of the shift sequence plus
e4a0d6cb
MK
70one, that is, the number of bytes written at
71.IR s .
fea681da 72.PP
e4a0d6cb
MK
73A third case is when
74.I s
75is NULL.
09725fbc 76In this case,
e4a0d6cb
MK
77.I wc
78is ignored,
c409c4ff 79and the function effectively returns
847e0d88 80.PP
d1a71985 81 wcrtomb(buf, L\(aq\e0\(aq, ps)
847e0d88 82.PP
1dcfd0de
MK
83where
84.I buf
85is an internal anonymous buffer.
fea681da 86.PP
e4a0d6cb
MK
87In all of the above cases, if
88.I ps
b437fdd9 89is NULL, a static anonymous
33a0ccb2 90state known only to the
60a90ecd
MK
91.BR wcrtomb ()
92function is used instead.
47297adb 93.SH RETURN VALUE
60a90ecd
MK
94The
95.BR wcrtomb ()
96function returns the number of
c13182ef 97bytes that have been or would
e4a0d6cb
MK
98have been written to the byte array at
99.IR s .
100If
101.I wc
102can not be
fea681da 103represented as a multibyte sequence (according to the current locale),
009df872 104.I (size_t)\ \-1
e4a0d6cb
MK
105is returned, and
106.I errno
107set to
108.BR EILSEQ .
3d597eca
ZL
109.SH ATTRIBUTES
110For an explanation of the terms used in this section, see
111.BR attributes (7).
112.TS
113allbox;
114lb lb lbw26
115l l l.
116Interface Attribute Value
117T{
118.BR wcrtomb ()
119T} Thread safety MT-Unsafe race:wcrtomb/!ps
120.TE
847e0d88 121.sp 1
47297adb 122.SH CONFORMING TO
f639deaf 123POSIX.1-2001, POSIX.1-2008, C99.
fea681da 124.SH NOTES
d9bfdb9c 125The behavior of
60a90ecd 126.BR wcrtomb ()
1274071a
MK
127depends on the
128.B LC_CTYPE
129category of the
fea681da
MK
130current locale.
131.PP
e4a0d6cb
MK
132Passing NULL as
133.I ps
134is not multithread safe.
47297adb 135.SH SEE ALSO
4670051b 136.BR mbsinit (3),
e37e3282 137.BR wcsrtombs (3)