mbstowcs converts multibyte characters to wide characters
/* * mbstowcs example code * http://code-reference.com/c/stdlib.h/mbstowcs */ #include <stdio.h> #include <stdlib.h> int main( void ) { char mbinput[8] = "\x54\x65\x73\x74\x20\x31\x32"; wchar_t output[8]; size_t wcssize; wcssize = mbstowcs(output, mbinput, 8); printf("mbstowcs returned %d\n", wcssize); printf("output: 0x%.4x 0x%.4x 0x%.4x 0x%.4x 0x%.4x 0x%.4x 0x%.4x \n", output[0], output[1], output[2], output[3], output[4], output[5], output[6], output[7]); return 0; }
user@host:~/code-reference.com# .//mbstowcs2 mbstowcs returned 7 output: 0x0054 0x0065 0x0073 0x0074 0x0020 0x0031 0x0032