https://bugzilla.novell.com/show_bug.cgi?id=235395
------- Comment #1 from mfabian@novell.com 2007-01-16 11:11 MST -------
A call to setlocale() is necessary to make the output work.
I.e. it the program is changed like this, it works:
mfabian@magellan:~/c$ cat bug235395.c
#include
#include
#include
#include
int main ()
{
const wchar_t *str = L"大家好\n";
FILE *fp = fopen ("utf.txt", "wb");
char *locale;
if ( NULL == (locale = setlocale(LC_ALL,""))) {
printf("locale not supported by glibc\n");
exit(1);
}
if (fwide (fp, 1) != 1) {
printf ("fail.\n");
return 0;
}
fputws(str, fp);
fprintf (fp, "%ls\n", str);
fputwc (0x4e00, fp);
fclose (fp);
}
mfabian@magellan:~/c$ gcc bug235395.c
mfabian@magellan:~/c$ ./a.out
mfabian@magellan:~/c$ cat utf.txt
大家好
一mfabian@magellan:~/c$
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.