For UTF-8 you code this:
DWORD dwBytesWritten = 0;
BOOL bErr = 0;
TCHAR *fname = TEXT("A_Unicode_WriteSTuff_天_file.txt");
HANDLE hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
unsigned char BOM[3]{ 0xef, 0xbb, 0xbf };
bErr = WriteFile(hFile, (LPCVOID)BOM, (DWORD)sizeof(BOM), &dwBytesWritten, NULL);
bErr = CloseHandle(hFile);