My intend is to write strings such as ñaäïüwiç
(utf-8 encoded) using WriteFile method.
So I have the following code:
#include <windows.h>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
int main(void) {
WCHAR str[] = L"ñaäïüwiç \n";
DWORD dwRead, dwWritten;
dwRead = (wcslen(str) + 1) * sizeof(WCHAR);
HANDLE hParentStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
BOOL bSuccess = WriteFile(hParentStdOut, str, dwRead, &dwWritten, NULL);
return 0;
}
What this small program does is to print the following instead:
± a õ ´ ³ w i þ
How do I solve this problem?