The C library function int mbtowc(whcar_t *pwc, const char *str, size_t n) converts a multibyte sequence to a wide character.
Following is the declaration for mbtowc() function.
int mbtowc(whcar_t *pwc, const char *str, size_t n)
The parameters are −
pwc − This is the pointer to an object of type wchar_t.
str − This is the pointer to the first byte of a multi-byte character.
str − This is the pointer to the first byte of a multi-byte character.
n −This is the maximum number of bytes to be checked for character length.
The return values are −
If str is not NULL, the mbtowc() function returns the number of consumed bytes starting at str, or 0 if s points to a null byte, or -1 upon failure.
If str is NULL, the mbtowc() function returns non-zero if the encoding has non-trivial shift state, or zero if the encoding is stateless.
Example
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main () {
char *str = "This is tutorialspoint.com";
wchar_t mb[100];
int len;
len = mblen(NULL, MB_CUR_MAX);
mbtowc(mb, str, len*strlen(str) );
wprintf(L"%ls \n", mb );
return(0);
}Output
???