C library function mblen()




C library function mblen()

#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main()
{
	int len;
	char *s = (char *)malloc(20);
	strcpy(s,"\xe4\xbd\xa0\xe5\xa5\xbd");

	/* resets the conversion state */
	mblen(NULL, 0);
	len = mblen(s,strlen(s));

	cout << "Length of multibyte character: " << len << endl;
	return 0;
}

Output

Length of multibyte character: 1