int mbtowc (wchar_t* pwc, const char* pmb, size_t max);
wchar_t
-1
123456789101112131415161718192021222324252627
/* mbtowc example */ #include <stdio.h> /* printf */ #include <stdlib.h> /* mbtowc, wchar_t(C) */ void printbuffer (const char* pt, size_t max) { int length; wchar_t dest; mbtowc (NULL, NULL, 0); /* reset mbtowc */ while (max>0) { length = mbtowc(&dest,pt,max); if (length<1) break; printf ("[%lc]",dest); pt+=length; max-=length; } } int main() { const char str [] = "mbtowc example"; printbuffer (str,sizeof(str)); return 0; }
"C"
[m][b][t][o][w][c][ ][e][x][a][m][p][l][e]