tcP handle of an existing tconv instance,
mbP location of multi-byte string,
errBrk error state decision flag.
Function tells the length of provided multi-byte string in wide-characters, the same way the strlen() does for standard ASCII strings. This value increased by one, can further be used to allocate HEAP memory for NULL-terminated, wide-character representation of that string.
To perform proper calculation, internal input character encoding needs to be set.
The errBrk property tells whether the string length calculation should be stopped in case of an error or not. If this value is greater than 0 (zero) and internal character conversion fails, the function detects this and returns with tconvError value.
/* C source */ #include <stdio.h> #include "tconv.h" void main(){ tconv *tcP; unsigned int wcLen; // 0xc485: UTF8 letter 'a+tail' char utf8S[] = {0xc4,0x85,'b','c','d','e',0}; tcP = tconv_init("pl_PL.utf8",NULL); wcLen = tconv_wcslen(tcP,utf8S,0); // 5 printf("wcLen is %i wide-chars long.\n", wcLen); tconv_free(tcP); }