mbrlen()

Count the bytes in a multibyte character (restartable)

Synopsis:

#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 you want to count.
ps
An internal pointer that lets mbrlen() be a restartable version of mblen(); if ps is NULL, mbrlen() uses its own internal variable.

You can call mbsinit() to determine the status of this variable.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The mbrlen() function counts the bytes in the multibyte character pointed to by s, to a maximum of n bytes.

Returns:

(size_t)-2
The resulting conversion state indicates an incomplete multibyte character after all n characters were converted.
(size_t)-1
The function detected an encoding error before completing the next multibyte character, in which case the function sets errno to EILSEQ and leaves the resulting conversion state undefined.
0
The next completed character is a null character, in which case the resulting conversion state is the initial conversion state.
x
The number of bytes needed to complete the next multibyte character, in which case the resulting conversion state indicates that x bytes have been converted.

Errors:

EILSEQ
Invalid character sequence.
EINVAL
The ps argument points to an invalid object.

Classification:

ANSI, POSIX 1003.1

Safety:  
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Read the Caveats

Caveats:

This function is safe to call in a multithreaded program if the ps argument isn't NULL.