man-pages/man3p/mbtowc.3p

93 lines
3.5 KiB
Plaintext

.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "MBTOWC" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" mbtowc
.SH NAME
mbtowc \- convert a character to a wide-character code
.SH SYNOPSIS
.LP
\fB#include <stdlib.h>
.br
.sp
int mbtowc(wchar_t *restrict\fP \fIpwc\fP\fB, const char *restrict\fP
\fIs\fP\fB, size_t\fP \fIn\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
If \fIs\fP is not a null pointer, \fImbtowc\fP() shall determine the
number of bytes that constitute the character pointed to
by \fIs\fP. It shall then determine the wide-character code for the
value of type \fBwchar_t\fP that corresponds to that
character. (The value of the wide-character code corresponding to
the null byte is 0.) If the character is valid and \fIpwc\fP is
not a null pointer, \fImbtowc\fP() shall store the wide-character
code in the object pointed to by \fIpwc\fP.
.LP
The behavior of this function is affected by the \fILC_CTYPE\fP category
of the current locale. For a state-dependent encoding,
this function is placed into its initial state by a call for which
its character pointer argument, \fIs\fP, is a null pointer.
Subsequent calls with \fIs\fP as other than a null pointer shall cause
the internal state of the function to be altered as
necessary. A call with \fIs\fP as a null pointer shall cause this
function to return a non-zero value if encodings have state
dependency, and 0 otherwise. If the implementation employs special
bytes to change the shift state, these bytes shall not produce
separate wide-character codes, but shall be grouped with an adjacent
character. Changing the \fILC_CTYPE\fP category causes the
shift state of this function to be unspecified. At most \fIn\fP bytes
of the array pointed to by \fIs\fP shall be examined.
.LP
The implementation shall behave as if no function defined in this
volume of IEEE\ Std\ 1003.1-2001 calls
\fImbtowc\fP().
.SH RETURN VALUE
.LP
If \fIs\fP is a null pointer, \fImbtowc\fP() shall return a non-zero
or 0 value, if character encodings, respectively, do or
do not have state-dependent encodings. If \fIs\fP is not a null pointer,
\fImbtowc\fP() shall either return 0 (if \fIs\fP points
to the null byte), or return the number of bytes that constitute the
converted character (if the next \fIn\fP or fewer bytes form
a valid character), or return -1 \ and may set \fIerrno\fP to indicate
the error (if they do not form a valid character).
.LP
In no case shall the value returned be greater than \fIn\fP or the
value of the {MB_CUR_MAX} macro.
.SH ERRORS
.LP
The \fImbtowc\fP() function may fail if:
.TP 7
.B EILSEQ
Invalid character sequence 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
\fImblen\fP() , \fImbstowcs\fP() , \fIwctomb\fP() , \fIwcstombs\fP()
, the Base Definitions volume of
IEEE\ Std\ 1003.1-2001, \fI<stdlib.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 .