MBLEN - length of multibyte character.

(ANSI Standard)

Usage:

#include <stdlib.h>
length = mblen(mb,N);

Where:

const char *mb;
is either a null pointer or a pointer to a character string containing the multibyte character to be examined.
size_t N;
gives a length, in bytes.
int length;
typically represents the length of the multibyte character (but see below for details).

Description:

The "mblen" function checks to see whether there is a valid multibyte character (in the current locale) beginning at the location indicated by "mb". The function only checks the first N bytes; therefore, it will only recognize multibyte characters whose length is less than or equal to N.

If "*mb" contains a valid multibyte character, "mblen" returns the number of bytes making up the character. This could be zero, if the string begins with '\0'. If the first N bytes of "mb" do not contain a valid multibyte character from the current locale, "mblen" returns -1.

Note that "mblen" returns a signed integer instead of an (unsigned) "size_t" value, as is usually used for measuring lengths.

If the "mb" argument is a null pointer, "mblen" returns 0 if multibyte characters do not have shift-dependencies, and a non-zero value otherwise.

NOTE: Since this version of C only recognizes single byte characters, all non-null strings start with a valid character whose length is 1.

See Also:

expl c lib mbtowc

expl c lib wctomb

Copyright © 1996, Thinkage Ltd.