diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 6183451df..4d846468a 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -138,9 +138,7 @@ void OS_Unix::alert(const String &p_alert, const String &p_title) { String OS_Unix::get_stdin_string() { char buff[1024]; - String ret = stdin_buf + fgets(buff, 1024, stdin); - stdin_buf = ""; - return ret; + return String::utf8(fgets(buff, 1024, stdin)); } String OS_Unix::get_name() const { diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 97bde6824..e40c10c5c 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -46,8 +46,6 @@ protected: virtual void finalize_core(); - String stdin_buf; - public: OS_Unix(); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 670ae9305..3d38571a2 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -3166,8 +3166,11 @@ bool OS_Windows::set_environment(const String &p_var, const String &p_value) con } String OS_Windows::get_stdin_string() { - char buff[1024]; - return fgets(buff, 1024, stdin); + WCHAR buff[1024]; + DWORD count = 0; + if (ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), buff, 1024, &count, nullptr)) { + return String::utf16((const char16_t *)buff, count); + } } void OS_Windows::enable_for_stealing_focus(ProcessID pid) {