Reading unicode file in c -
i want read read unicode text file in normal c. following code not working same,
#include<stdio.h> int main() { file *ptr_file; char buf[1000]; ptr_file =fopen("input.txt","r"); if (!ptr_file) return 1; while (fgets(buf,1000, ptr_file)!=null) printf("%s",buf); fclose(ptr_file); return 0; }
try this:
#include <locale.h> #include <stdio.h> #include <wchar.h> int main() { file *input; wchar_t buf[1000]; setlocale(lc_ctype,"it_it.utf-8"); // put locale here if ((input = fopen("input.txt","r")) == null) return 1; while (fgetws(buf,1000,input)!=null) wprintf(l"%s",buf); fclose(input); }
Comments
Post a Comment