summaryrefslogtreecommitdiffstats
path: root/man-pages-posix-2003/man3p/wcrtomb.3p
blob: e66b951c29967b073866bf3282f1217d903bf089 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "WCRTOMB" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" wcrtomb 
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.SH NAME
wcrtomb \- convert a wide-character code to a character (restartable)
.SH SYNOPSIS
.LP
\fB#include <stdio.h>
.br
.sp
size_t wcrtomb(char *restrict\fP \fIs\fP\fB, wchar_t\fP \fIwc\fP\fB,
mbstate_t *restrict\fP \fIps\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
If \fIs\fP is a null pointer, the \fIwcrtomb\fP() function shall be
equivalent to the call:
.sp
.RS
.nf

\fBwcrtomb(\fP\fIbuf\fP\fB, L'\\0',\fP \fIps\fP\fB)
\fP
.fi
.RE
.LP
where \fIbuf\fP is an internal buffer.
.LP
If \fIs\fP is not a null pointer, the \fIwcrtomb\fP() function shall
determine the number of bytes needed to represent the
character that corresponds to the wide character given by \fIwc\fP
(including any shift sequences), and store the resulting bytes
in the array whose first element is pointed to by \fIs\fP. At most
{MB_CUR_MAX} bytes are stored. If \fIwc\fP is a null wide
character, a null byte shall be stored, preceded by any shift sequence
needed to restore the initial shift state. The resulting
state described shall be the initial conversion state.
.LP
If \fIps\fP is a null pointer, the \fIwcrtomb\fP() function shall
use its own internal \fBmbstate_t\fP object, which is
initialized at program start-up to the initial conversion state. Otherwise,
the \fBmbstate_t\fP object pointed to by \fIps\fP
shall be used to completely describe the current conversion state
of the associated character sequence. The implementation shall
behave as if no function defined in this volume of IEEE\ Std\ 1003.1-2001
calls \fIwcrtomb\fP().
.LP
If
the application uses any of the _POSIX_THREAD_SAFE_FUNCTIONS or _POSIX_THREADS
functions, the application shall ensure that the
\fIwcrtomb\fP() function is called with a non-NULL \fIps\fP argument.
.LP
The behavior of this function shall be affected by the \fILC_CTYPE\fP
category of the current locale.
.SH RETURN VALUE
.LP
The \fIwcrtomb\fP() function shall return the number of bytes stored
in the array object (including any shift sequences). When
\fIwc\fP is not a valid wide character, an encoding error shall occur.
In this case, the function shall store the value of the
macro [EILSEQ] in \fIerrno\fP and shall return (\fBsize_t\fP)-1; the
conversion state shall be undefined.
.SH ERRORS
.LP
The \fIwcrtomb\fP() function may fail if:
.TP 7
.B EINVAL
\fIps\fP points to an object that contains an invalid conversion state.
.TP 7
.B EILSEQ
Invalid wide-character code is detected.
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
None.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fImbsinit\fP(), the Base Definitions volume of IEEE\ Std\ 1003.1-2001,
\fI<wchar.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .