From 1539bed3db86f2153f2d0d5fbf24bf9ee4af1d92 Mon Sep 17 00:00:00 2001 From: Mikhail Redko Date: Sun, 11 Apr 2021 20:41:44 +0300 Subject: Core/Misc: Fixed utf8 encoding in console input/output. (#26352) * Core/Misc: Fixed utf8 encoding in console input/output. * Fix gcc build * Fixed that weird 'a' with circle above it and other similar letters. Also fixed encoding in AppenderConsole which sometimes did not work as it should * Fix build on Linux * Probably better to do it like this --- src/server/worldserver/CommandLine/CliRunnable.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/server') diff --git a/src/server/worldserver/CommandLine/CliRunnable.cpp b/src/server/worldserver/CommandLine/CliRunnable.cpp index 7b2624159ef..2d858c415d4 100644 --- a/src/server/worldserver/CommandLine/CliRunnable.cpp +++ b/src/server/worldserver/CommandLine/CliRunnable.cpp @@ -78,11 +78,7 @@ namespace Trinity::Impl::Readline void utf8print(void* /*arg*/, std::string_view str) { #if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS - std::wstring wbuf; - if (!Utf8toWStr(str, wbuf)) - return; - - wprintf(L"%s", wbuf.c_str()); + WriteWinConsole(str); #else { printf(STRING_VIEW_FMT, STRING_VIEW_FMT_ARG(str)); @@ -139,14 +135,10 @@ void CliThread() std::string command; #if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS - wchar_t commandbuf[256]; - if (fgetws(commandbuf, sizeof(commandbuf), stdin)) + if (!ReadWinConsole(command)) { - if (!WStrToUtf8(commandbuf, wcslen(commandbuf), command)) - { - PrintCliPrefix(); - continue; - } + PrintCliPrefix(); + continue; } #else char* command_str = readline(CLI_PREFIX); -- cgit v1.2.3