Fix platform_get_username for unicode on Windows

This commit is contained in:
Ted John 2018-09-18 12:29:29 +01:00
parent 8ce6cde2b7
commit 2da2aa5622
1 changed files with 5 additions and 4 deletions

View File

@ -509,15 +509,16 @@ datetime64 platform_get_datetime_now_utc()
utf8* platform_get_username()
{
static char username[UNLEN + 1];
static wchar_t usernameW[UNLEN + 1];
DWORD usernameLength = UNLEN + 1;
if (!GetUserName(username, &usernameLength))
if (!GetUserNameW(usernameW, &usernameLength))
{
return nullptr;
}
return username;
static std::string username;
username = widechar_to_utf8(usernameW);
return username.data();
}
bool platform_process_is_elevated()