mblen(), mblen_l()

determine length of multibyte character 

Function


SYNOPSIS

#include <stdlib.h>

int mblen(const char *s, size_t n);

#include <stdlib.h>

#include <locale.h>

int mblen_l(const char *s, size_t n, locale_t locale);


DESCRIPTION

The mblen() and mblen_l() functions determine the length, in bytes, of the multibyte character pointed to by s.

mblen_l() behaves in the same way as mblen() without the _l suffix, but uses the specified locale rather than the global or per-thread locale. A locale_t is returned by newlocale().


PARAMETERS

s 

Pointer to multibyte character.

n 

Maximum number of bytes to examine for a multibyte character encoding. Regardless of the value of n, no more than MB_CUR_MAX (or MB_CUR_MAX_L) bytes are scanned.

locale 

Is a locale_t perhaps returned by newlocale() or LC_GLOBAL_LOCALE or 0 for the current thread locale set with uselocale().


RETURN VALUES

The functions mblen() and mblen_l() returns the length, in bytes, of the multibyte character pointed to by s. If s is NULL or s points to multibyte null character, mblen() returns zero. If s points to an invalid multibyte character, mblen() and mblen_l() return -1.


CONFORMANCE

mblen() conforms to ANSI/ISO 9899:1999 'ISO C99' mblen_l() conforms to IEEE Std 1003.1-2008 'POSIX.1'


MULTITHREAD SAFETY LEVEL

MT-Safe, with exceptions.

The mblen() function is MT-Safe as long as no thread calls setlocale() while this function is executing.

The function mblen_l() is MT-Safe as long as no thread calls freelocale() on locale while this function is executing.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
mbtowc(), mbtowc_l(), newlocale(), setlocale(), strlen(), wctomb(), wctomb_l()


PTC MKS Toolkit 10.4 Documentation Build 39.