Format
#include <stdlib.h> int mblen(const char *string, size_t n);
Language Level: ANSI
Threadsafe: No. Use mbrlen() instead.
Description
The mblen() function determines the length in bytes of the multibyte character pointed to by string. n represents the maximum number of bytes examined.
Return Value
If string is NULL, the mblen() function returns:
If string is not NULL, mblen() returns:
Example that uses mblen()
This example uses mblen() and mbtowc() to convert a multibyte character into a single wide character.
#include <stdio.h> #include <stdlib.h> int length, temp; char string [6] = "w"; wchar_t arr[6]; int main(void) { /* Initialize internal state variable */ length = mblen(NULL, MB_CUR_MAX); /* Set string to point to a multibyte character */ length = mblen(string, MB_CUR_MAX); temp = mbtowc(arr,string,length); arr[1] = L'\0'; printf("wide character string: %ls\n", arr); }
Related Information
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.