Syntax
#include <stdlib.h> int mblen(const char *string, size_t n);Description
mblen determines the length in bytes of the multibyte character pointed to by string. A maximum of n bytes is examined.
The behavior of mblen is affected by the LC_CTYPE category of the current locale.
If string is NULL, mblen returns 0.
If string is not NULL, mblen returns:
This example uses mblen and mbtowc to convert a multibyte character into a single wide character.
#include <stdio.h>#include <stdlib.h> #include <wchar.h> #include <locale.h> int main(void) { char mb_string[] = "\x81\x41\x81\xc2" "b"; int length; wchar_t widechar; if (NULL == setlocale(LC_ALL, "ja_jp.ibm-932")) { printf("setlocale failed.\n"); exit(EXIT_FAILURE); } length = mblen(mb_string, MB_CUR_MAX); mbtowc(&widechar, mb_string, length); printf("The wide character %lc has length of %d.\n", widechar, length); return 0; /**************************************************************************** The output should be similar to : The wide character žA has length of 2. ****************************************************************************/ }Related Information