You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Fix reading Unicode from stdio.
This commit is contained in:
@@ -152,12 +152,10 @@ Vector<String> OS_Unix::get_video_adapter_driver_info() const {
|
|||||||
String OS_Unix::get_stdin_string(bool p_block) {
|
String OS_Unix::get_stdin_string(bool p_block) {
|
||||||
if (p_block) {
|
if (p_block) {
|
||||||
char buff[1024];
|
char buff[1024];
|
||||||
String ret = stdin_buf + fgets(buff, 1024, stdin);
|
return String::utf8(fgets(buff, 1024, stdin));
|
||||||
stdin_buf = "";
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
Error OS_Unix::get_entropy(uint8_t *r_buffer, int p_bytes) {
|
Error OS_Unix::get_entropy(uint8_t *r_buffer, int p_bytes) {
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ protected:
|
|||||||
|
|
||||||
virtual void finalize_core() override;
|
virtual void finalize_core() override;
|
||||||
|
|
||||||
String stdin_buf;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OS_Unix();
|
OS_Unix();
|
||||||
|
|
||||||
|
|||||||
@@ -1164,8 +1164,11 @@ bool OS_Windows::set_environment(const String &p_var, const String &p_value) con
|
|||||||
|
|
||||||
String OS_Windows::get_stdin_string(bool p_block) {
|
String OS_Windows::get_stdin_string(bool p_block) {
|
||||||
if (p_block) {
|
if (p_block) {
|
||||||
char buff[1024];
|
WCHAR buff[1024];
|
||||||
return fgets(buff, 1024, stdin);
|
DWORD count = 0;
|
||||||
|
if (ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), buff, 1024, &count, nullptr)) {
|
||||||
|
return String::utf16((const char16_t *)buff, count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return String();
|
return String();
|
||||||
|
|||||||
Reference in New Issue
Block a user