Im trying to write to a file with unicode but when i use _wfopen i get extra spaces between the letters like
H e l l o
instead of
Hello.
I cant figure out why.
Code:
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <wchar.h>
#define BUFFER_SIZE 50
int main(int argc, char** argv)
{
wchar_t str[BUFFER_SIZE];
size_t strSize;
FILE* fileHandle;
if ((fileHandle = _wfopen( L"_wfopen_test.txt",L"wt+,ccs=UNICODE")) == NULL)
{
wprintf(L"_wfopen failed!\n");
return(0);
}
wcscpy_s(str, sizeof(str)/sizeof(wchar_t), L"Hello\n");
strSize = wcslen(str);
if (fwrite(str, sizeof(wchar_t), strSize, fileHandle) != strSize)
{
wprintf(L"fwrite failed!\n");
}
if (fclose(fileHandle))
{
wprintf(L"fclose failed!\n");
}
return 0;
}