Skip to content

Instantly share code, notes, and snippets.

@117503445
Created May 31, 2020 09:57
Show Gist options
  • Save 117503445/1b0ef3a79bb0a16c7c6175296370700a to your computer and use it in GitHub Desktop.
Save 117503445/1b0ef3a79bb0a16c7c6175296370700a to your computer and use it in GitHub Desktop.
C : read and write UTF-8 file
/* fgetwc example */
#include <stdio.h>
#include <wchar.h>
int main()
{
FILE *fin;
FILE *fout;
wint_t wc;
fin = fopen("in.txt", "r");
fout = fopen("out.txt", "w");
while ((wc = fgetwc(fin)) != WEOF)
{
printf("%c",wc);
fputwc(wc,fout);
}
fclose(fin);
fclose(fout);
printf("File has been created...\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment