Assuming you are using MSVC, quote the documentation for _ wfopen (bold mines):
fopen , . _wfopen - fopen; _wfopen - . , _wfopen fopen . _wfopen .
:
fopen Unicode. Unicode, ccs, foken, .
fopen (& fp, "newfile.txt", "rw, ccs = encoding" );
UNICODE, UTF-8 UTF-16LE.
UTF-8. UTF-16BE, UTF-16LE UTF-8, MSVC .
#include <stdio.h>
int main()
{
FILE* oFile;
oFile = fopen("foo.txt","w, ccs=UTF-8");
fwprintf(oFile,L"%s", L"ęłó☺☻♥♦•ń");
fclose(oFile);
return 0;
}
, Windows UTF-8:
C:\x>chcp
Active code page: 1252
C:\x>x
C:\x>type foo.txt
ęłó☺☻♥♦•ń
C:\Users\metolone\Desktop\x>chcp 65001
Active code page: 65001
C:\x>type foo.txt
ęłó☺☻♥♦•ń