From 2da2aa56223dde0132db1175ea246eb0748e4c03 Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 18 Sep 2018 12:29:29 +0100 Subject: [PATCH] Fix platform_get_username for unicode on Windows --- src/openrct2/platform/Windows.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/openrct2/platform/Windows.cpp b/src/openrct2/platform/Windows.cpp index 6b15029f10..437997b717 100644 --- a/src/openrct2/platform/Windows.cpp +++ b/src/openrct2/platform/Windows.cpp @@ -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()