c - Invalid localized chars in a text file -
i larn c language. need create text file unicode data. have wrote such code:
#include<stdio.h> #include<stdlib.h> #include<wchar.h> int main(int argc, char *argv[]) { wchar_t *s1 = l"Привет, мир!\n"; wchar_t *s2 = l"hello, world!"; file *fp = fopen("./hello.txt", "w"); fputws(s1, fp); fputws(s2, fp); fclose(fp); exit(exit_success); }
but such result:
??????, ???! hello, world!
why don't russian chars?
it possible having problem locales in terminal running program. if so, have set locale this:
setlocale(lc_ctype,"");
more info here
c unicode wchar-t c89
No comments:
Post a Comment