mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-07 12:50:38 +08:00
engine: system: convert Windows username to utf8
This commit is contained in:
@@ -128,11 +128,17 @@ const char *Sys_GetCurrentUser( void )
|
||||
{
|
||||
// TODO: move to platform
|
||||
#if XASH_WIN32
|
||||
static string s_userName;
|
||||
unsigned long size = sizeof( s_userName );
|
||||
static wchar_t sw_userName[MAX_STRING];
|
||||
DWORD size = ARRAYSIZE( sw_userName );
|
||||
|
||||
if( GetUserName( s_userName, &size ))
|
||||
if( GetUserNameW( sw_userName, &size ) && sw_userName[0] != 0 )
|
||||
{
|
||||
static char s_userName[MAX_STRING * 4];
|
||||
|
||||
// set length to -1, so it will null terminate
|
||||
WideCharToMultiByte( CP_UTF8, 0, sw_userName, -1, s_userName, sizeof( s_userName ), NULL, NULL );
|
||||
return s_userName;
|
||||
}
|
||||
#elif XASH_PSVITA
|
||||
static string username;
|
||||
sceAppUtilSystemParamGetString( SCE_SYSTEM_PARAM_ID_USERNAME, username, sizeof( username ) - 1 );
|
||||
|
||||
Reference in New Issue
Block a user