[Previous] [Contents] [Next]

mbrlen()

Get the number of bytes in a character

Synopsis:

#include <wchar.h>

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

Library:

libc

Description:

The mbrlen() function counts the bytes in the multibyte character pointed to by s, to a maximum of n bytes. The ps variable is an internal pointer that allows mbrlen() to be a restartable version of mblen(); if ps is NULL, mbrlen() uses its own internal variable.

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 stores the value EILSEQ in errno 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
ps points to an invalid object.

Classification:

ANSI

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

errno()

"Character manipulation functions" and "Wide-character functions" in the summary of functions chapter.


[Previous] [Contents] [Next]