1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
/* wctomb example */
#include <stdio.h> /* printf */
#include <stdlib.h> /* wctomb, wchar_t(C) */
int main() {
const wchar_t str[] = L"wctomb example";
const wchar_t* pt;
char buffer [MB_CUR_MAX];
int i,length;
pt = str;
while (*pt) {
length = wctomb(buffer,*pt);
if (length<1) break;
for (i=0;i<length;++i) printf ("[%c]",buffer[i]);
++pt;
}
return 0;
}
|