mbrlen

Determines the number of bytes comprising a multibyte character.

Format

#include  <wchar.h>

size_t mbrlen  (const char *s, size_t n, mbstate_t
               *ps);

Arguments

s
A pointer to a multibyte character.
n
The maximum number of bytes that comprise the multibyte character.
ps
A pointer to the mbstate_t object. If a NULL pointer is specified, the function uses its internal mbstate_t object.

Description

The mbrlen function is equivalent to the call:
    mbrtowc(NULL, s, n, ps != NULL ? ps : &internal)

Where internal is the mbstate_t object for the mbrlen function.

If the multibyte character pointed to by s is of n bytes or less, the function returns the number of bytes comprising the character (including any shift sequences).

If either an encoding error occurs or the next n bytes contribute to an incomplete but potentially valid multibyte character, the function returns -1 or -2, respectively.

See also mbrtowc in this section.

Return Values
The number of bytes comprising the multibyte character. 
Indicates that s is a NULL pointer or a pointer to a null byte. 
-1  Indicates an encoding error, in which case the next n or fewer bytes do not contribute to a complete and valid multibyte character. errno is set to EILSEQ; the conversion state is undefined. 
-2  Indicates an incomplete but potentially valid multibyte character (all n bytes have been processed). 


Previous Page | Next Page | Table of Contents | Index