.\" 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 .
|