I'm revisiting an issue I encountered a long time ago. I now consistently use this method to handle UTF-8 encoding. It requires Windows, but it works reliably with C/C++. I'll provide the corrected source code that delivers the best results.
#include <stdio.h>
#include <stdbool.h>
#include <windows.h>
bool file_read(char name[]){
FILE *files = NULL;
files = fopen(name, "r");
if(files == NULL){
return false;
}else{
char Carack;
while ((Carack = fgetc(files)) != EOF){
printf("%c", Carack);
}
}
printf("\n");
fclose(files);
return true;
}
int main(){
SetConsoleOutputCP(CP_UTF8); // UTF 8 support
file_read("d.txt");
}