|
Packit |
7cfc04 |
.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
|
|
Packit |
7cfc04 |
.\" This is free documentation; you can redistribute it and/or
|
|
Packit |
7cfc04 |
.\" modify it under the terms of the GNU General Public License as
|
|
Packit |
7cfc04 |
.\" published by the Free Software Foundation; either version 2 of
|
|
Packit |
7cfc04 |
.\" the License, or (at your option) any later version.
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" References consulted:
|
|
Packit |
7cfc04 |
.\" GNU glibc-2 source code and manual
|
|
Packit |
7cfc04 |
.\" Dinkumware C library reference http://www.dinkumware.com/
|
|
Packit |
7cfc04 |
.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
|
|
Packit |
7cfc04 |
.\" ISO/IEC 9899:1999
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH MBLEN 3 2015-08-08 "GNU" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
mblen \- determine number of bytes in next multibyte character
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
.B #include <stdlib.h>
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BI "int mblen(const char *" s ", size_t " n );
|
|
Packit |
7cfc04 |
.fi
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.I s
|
|
Packit |
7cfc04 |
is not NULL, the
|
|
Packit |
7cfc04 |
.BR mblen ()
|
|
Packit |
7cfc04 |
function inspects at most
|
|
Packit |
7cfc04 |
.I n
|
|
Packit |
7cfc04 |
bytes of the multibyte string starting at
|
|
Packit |
7cfc04 |
.I s
|
|
Packit |
7cfc04 |
and extracts the
|
|
Packit |
7cfc04 |
next complete multibyte character.
|
|
Packit |
7cfc04 |
It uses a static anonymous shift state known only to the
|
|
Packit |
7cfc04 |
.BR mblen ()
|
|
Packit |
7cfc04 |
function.
|
|
Packit |
7cfc04 |
If the multibyte character is not the null wide
|
|
Packit |
7cfc04 |
character, it returns the number of bytes that were consumed from
|
|
Packit |
7cfc04 |
.IR s .
|
|
Packit |
7cfc04 |
If the multibyte character is the null wide character, it returns 0.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If the
|
|
Packit |
7cfc04 |
.IR n
|
|
Packit |
7cfc04 |
bytes starting at
|
|
Packit |
7cfc04 |
.I s
|
|
Packit |
7cfc04 |
do not contain a complete multibyte
|
|
Packit |
7cfc04 |
character,
|
|
Packit |
7cfc04 |
.BR mblen ()
|
|
Packit |
7cfc04 |
returns \-1.
|
|
Packit |
7cfc04 |
This can happen even if
|
|
Packit |
7cfc04 |
.I n
|
|
Packit |
7cfc04 |
is greater than or equal to
|
|
Packit |
7cfc04 |
.IR MB_CUR_MAX ,
|
|
Packit |
7cfc04 |
if the multibyte string contains redundant shift sequences.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If the multibyte string starting at
|
|
Packit |
7cfc04 |
.I s
|
|
Packit |
7cfc04 |
contains an invalid multibyte
|
|
Packit |
7cfc04 |
sequence before the next complete character,
|
|
Packit |
7cfc04 |
.BR mblen ()
|
|
Packit |
7cfc04 |
also returns \-1.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.I s
|
|
Packit |
7cfc04 |
is NULL, the
|
|
Packit |
7cfc04 |
.BR mblen ()
|
|
Packit |
7cfc04 |
function
|
|
Packit |
7cfc04 |
.\" The Dinkumware doc and the Single UNIX specification say this, but
|
|
Packit |
7cfc04 |
.\" glibc doesn't implement this.
|
|
Packit |
7cfc04 |
resets the shift state, known to only this function, to the initial state, and
|
|
Packit |
7cfc04 |
returns nonzero if the encoding has nontrivial shift state, or zero if the
|
|
Packit |
7cfc04 |
encoding is stateless.
|
|
Packit |
7cfc04 |
.SH RETURN VALUE
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.BR mblen ()
|
|
Packit |
7cfc04 |
function returns the number of
|
|
Packit |
7cfc04 |
bytes parsed from the multibyte
|
|
Packit |
7cfc04 |
sequence starting at
|
|
Packit |
7cfc04 |
.IR s ,
|
|
Packit |
7cfc04 |
if a non-null wide character was recognized.
|
|
Packit |
7cfc04 |
It returns 0, if a null wide character was recognized.
|
|
Packit |
7cfc04 |
It returns \-1, if an
|
|
Packit |
7cfc04 |
invalid multibyte sequence was encountered or if it couldn't parse a complete
|
|
Packit |
7cfc04 |
multibyte character.
|
|
Packit |
7cfc04 |
.SH ATTRIBUTES
|
|
Packit |
7cfc04 |
For an explanation of the terms used in this section, see
|
|
Packit |
7cfc04 |
.BR attributes (7).
|
|
Packit |
7cfc04 |
.TS
|
|
Packit |
7cfc04 |
allbox;
|
|
Packit |
7cfc04 |
lb lb lb
|
|
Packit |
7cfc04 |
l l l.
|
|
Packit |
7cfc04 |
Interface Attribute Value
|
|
Packit |
7cfc04 |
T{
|
|
Packit |
7cfc04 |
.BR mblen ()
|
|
Packit |
7cfc04 |
T} Thread safety MT-Unsafe race
|
|
Packit |
7cfc04 |
.TE
|
|
Packit |
7cfc04 |
.SH CONFORMING TO
|
|
Packit |
7cfc04 |
POSIX.1-2001, POSIX.1-2008, C99.
|
|
Packit |
7cfc04 |
.SH NOTES
|
|
Packit |
7cfc04 |
The behavior of
|
|
Packit |
7cfc04 |
.BR mblen ()
|
|
Packit |
7cfc04 |
depends on the
|
|
Packit |
7cfc04 |
.B LC_CTYPE
|
|
Packit |
7cfc04 |
category of the
|
|
Packit |
7cfc04 |
current locale.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The function
|
|
Packit |
7cfc04 |
.BR mbrlen (3)
|
|
Packit |
7cfc04 |
provides a better interface to the same
|
|
Packit |
7cfc04 |
functionality.
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR mbrlen (3)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|