| 1 |
#include <stdio.h> |
| 2 |
#include <stdlib.h> |
| 3 |
#include <wchar.h> |
| 4 |
#include <errno.h> |
| 5 |
#include <string.h> |
| 6 |
#include <locale.h> |
| 7 |
|
| 8 |
int main() { |
| 9 |
|
| 10 |
wchar_t wstr[2]; |
| 11 |
char str[5]; |
| 12 |
size_t i; |
| 13 |
|
| 14 |
setlocale(LC_ALL, ""); |
| 15 |
|
| 16 |
wstr[0] = 0x8428; /* Unicode CJK U+8428 */ |
| 17 |
wstr[1] = 0x0; |
| 18 |
|
| 19 |
for (i=0;i<sizeof(str);i++) |
| 20 |
str[i]='\0'; |
| 21 |
|
| 22 |
if (wcstombs(str, wstr, sizeof(str)) != (size_t)-1) { |
| 23 |
for (i=0;i<sizeof(str);i++) |
| 24 |
fprintf(stdout,"%02X ",(unsigned char)str[i]); |
| 25 |
fprintf(stdout,"\n"); |
| 26 |
/* fprintf(stdout,"%s\n",str); */ |
| 27 |
fprintf(stdout,"PASS\n"); |
| 28 |
return 0; |
| 29 |
} else { |
| 30 |
const char *errstr = strerror(errno); |
| 31 |
fprintf(stdout,"%s\n",errstr); |
| 32 |
fprintf(stdout,"FAIL\n"); |
| 33 |
return 1; |
| 34 |
} |
| 35 |
|
| 36 |
} |