I'm a n00b to unicode so go easy on me, I'm also the type who likes to code first and read documentation later.
I'm trying to read a unicode file, and I've pretty much got it working. But there is a bit that I'm not quite certain about, so here we go.
I'm opening and reading the file like this:
In summary of the below variables, the important ones:
char buff - contains the file, read from readFile()
char mbbuff - contains result of WideCharToMultiByte()
And when all is said and done, I just set the edit text to mbbuff. I'm assuming it's just me not setting the correct properties for the control because I'm getting weird chars and stuff everywhere. Including some that usually appear when you try to write from a buffer that has no text or whatever so I've got a bit of a memory problem as well I'm afraid.Code:HANDLE file = CreateFile( "eng.utxt", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( file == INVALID_HANDLE_VALUE ) MessageBox( NULL, "Failed to open eng.utxt!", "Error", MB_OK | MB_ICONERROR ); DWORD SIZE = GetFileSize( file, NULL );//40000; WCHAR buff[SIZE]; DWORD numread; bool rf = ReadFile( file, buff, SIZE, &numread, NULL ); if( !rf ) MessageBox( NULL, "ReadFile() Failed!", "Error", MB_OK | MB_ICONERROR ); CloseHandle( file ); char mbbuff[SIZE]; WideCharToMultiByte( CP_UTF8, 0, buff, SIZE, mbbuff, SIZE, NULL, NULL );