engine: platform: win32: request error string in wide chars and then transform it to UTF-8 using our utflib
This commit is contained in:
parent
166bed732e
commit
a1191eb4ab
1 changed files with 12 additions and 10 deletions
|
@ -296,15 +296,17 @@ table_error:
|
||||||
|
|
||||||
static const char *GetLastErrorAsString( void )
|
static const char *GetLastErrorAsString( void )
|
||||||
{
|
{
|
||||||
|
const DWORD fm_flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK;
|
||||||
DWORD errorcode;
|
DWORD errorcode;
|
||||||
|
wchar_t wide_errormessage[256];
|
||||||
static string errormessage;
|
static string errormessage;
|
||||||
|
|
||||||
errorcode = GetLastError();
|
errorcode = GetLastError();
|
||||||
if ( !errorcode ) return "";
|
if ( !errorcode )
|
||||||
|
return "";
|
||||||
|
|
||||||
FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
|
FormatMessageW( fm_flags, NULL, errorcode, 0, wide_errormessage, ARRAYSIZE( wide_errormessage ), NULL );
|
||||||
NULL, errorcode, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
|
Q_UTF16ToUTF8( errormessage, sizeof( errormessage ), wide_errormessage, ARRAYSIZE( wide_errormessage ));
|
||||||
(LPSTR)&errormessage, sizeof( errormessage ), NULL );
|
|
||||||
|
|
||||||
return errormessage;
|
return errormessage;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue