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

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 "MBRLEN" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" mbrlen 
.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
mbrlen \- get number of bytes in a character (restartable)
.SH SYNOPSIS
.LP
\fB#include <wchar.h>
.br
.sp
size_t mbrlen(const char *restrict\fP \fIs\fP\fB, size_t\fP \fIn\fP\fB,
.br
\ \ \ \ \ \  mbstate_t *restrict\fP \fIps\fP\fB);
.br
\fP
.SH DESCRIPTION
.LP
If \fIs\fP is not a null pointer, \fImbrlen\fP() shall determine the
number of bytes constituting the character pointed to by
\fIs\fP. It shall be equivalent to:
.sp
.RS
.nf

\fBmbstate_t internal;
mbrtowc(NULL, s, n, ps != NULL ? ps : &internal);
\fP
.fi
.RE
.LP
If \fIps\fP is a null pointer, the \fImbrlen\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 \fImbrlen\fP().
.LP
The behavior of this function is affected by the \fILC_CTYPE\fP category
of the current locale.
.SH RETURN VALUE
.LP
The \fImbrlen\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.
.TP 7
\fIpositive\fP
If the next \fIn\fP or fewer bytes complete a valid character; 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. 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. In this case, [EILSEQ] shall be stored in \fIerrno\fP and
the conversion state is undefined.
.sp
.SH ERRORS
.LP
The \fImbrlen\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(), \fImbrtowc\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.