From eb43c99f47406d274dac13c8ba3bf7154499f093 Mon Sep 17 00:00:00 2001 From: Josh Yelon Date: Thu, 18 May 2023 21:33:54 -0400 Subject: [PATCH] Fixed unicode support under windows console --- luprex/cpp/drv/driver-windows.cpp | 5 +++-- luprex/cpp/drv/driver.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/luprex/cpp/drv/driver-windows.cpp b/luprex/cpp/drv/driver-windows.cpp index 5b945bd0..da5c8356 100644 --- a/luprex/cpp/drv/driver-windows.cpp +++ b/luprex/cpp/drv/driver-windows.cpp @@ -3,6 +3,7 @@ #include "drvutil.hpp" #include "sslutil.hpp" +#include "readline.hpp" #include "../core/enginewrapper.hpp" #include @@ -233,8 +234,8 @@ static void console_write(const CodepointString &cps) { if (cps.size() == 0) return; // Convert to wstring. // Any character outside the range 0xFFFF is replaced with a box. - std::wstring ws(cps.size()); - for (int i = 0; i < cps.size(); i++) { + std::wstring ws(cps.size(), 0); + for (int i = 0; i < int(cps.size()); i++) { char32_t c = cps[i]; if ((c >= 0)&&(c <= 0xFFFF)) ws[i] = (wchar_t)c; else ws[i] = 0x2610; diff --git a/luprex/cpp/drv/driver.cpp b/luprex/cpp/drv/driver.cpp index 5369ffde..694705f8 100644 --- a/luprex/cpp/drv/driver.cpp +++ b/luprex/cpp/drv/driver.cpp @@ -477,7 +477,7 @@ class Driver { void handle_socket_input_output() { std::string err; - int mstimeout = read_console_recently_ ? 100 : 1000; + int mstimeout = read_console_recently_ ? 10 : 100; // Peek output buffers and determine channel release flags. bool any_released = false;