Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/lib/ape/man/3/mbrtowc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "MBRTOWC" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" mbrtowc 
.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
mbrtowc \- convert a character to a wide-character code (restartable)
.SH SYNOPSIS
.LP
\fB#include <wchar.h>
.br
.sp
size_t mbrtowc(wchar_t *restrict\fP \fIpwc\fP\fB, const char *restrict\fP
\fIs\fP\fB,
.br
\ \ \ \ \ \  size_t\fP \fIn\fP\fB, mbstate_t *restrict\fP \fIps\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
If \fIs\fP is a null pointer, the \fImbrtowc\fP() function shall be
equivalent to the call:
.sp
.RS
.nf

\fBmbrtowc(NULL, "", 1, ps)
\fP
.fi
.RE
.LP
In this case, the values of the arguments \fIpwc\fP and \fIn\fP are
ignored.
.LP
If \fIs\fP is not a null pointer, the \fImbrtowc\fP() function shall
inspect at most \fIn\fP bytes beginning at the byte
pointed to by \fIs\fP to determine the number of bytes needed to complete
the next character (including any shift sequences). If
the function determines that the next character is completed, it shall
determine the value of the corresponding wide character and
then, if \fIpwc\fP is not a null pointer, shall store that value in
the object pointed to by \fIpwc\fP. If the corresponding wide
character is the null wide character, the resulting state described
shall be the initial conversion state.
.LP
If \fIps\fP is a null pointer, the \fImbrtowc\fP() function shall
use its own internal \fBmbstate_t\fP object, which shall be
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 \fImbrtowc\fP().
.LP
The behavior of this function is affected by the \fILC_CTYPE\fP category
of the current locale.
.SH RETURN VALUE
.LP
The \fImbrtowc\fP() function shall return the first of the following
that applies:
.TP 7
0
If the next \fIn\fP or fewer bytes complete the character that corresponds
to the null wide character (which is the value
stored).
.TP 7
between 1 and \fIn\fP inclusive
.sp
If the next \fIn\fP or fewer bytes complete a valid character (which
is the value stored); the value returned shall be the number
of bytes that complete the character.
.TP 7
(\fBsize_t\fP)-2
If the next \fIn\fP bytes contribute to an incomplete but potentially
valid character, and all \fIn\fP bytes have been
processed (no value is stored). When \fIn\fP has at least the value
of the {MB_CUR_MAX} macro, this case can only occur if
\fIs\fP points at a sequence of redundant shift sequences (for implementations
with state-dependent encodings).
.TP 7
(\fBsize_t\fP)-1
If an encoding error occurs, in which case the next \fIn\fP or fewer
bytes do not contribute to a complete and valid character
(no value is stored). In this case, [EILSEQ] shall be stored in \fIerrno\fP
and the conversion state is undefined.
.sp
.SH ERRORS
.LP
The \fImbrtowc\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 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
\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 .

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.