mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
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
(cherry picked from commit 1539bed3db)
This commit is contained in:
@@ -162,6 +162,15 @@ void AppenderConsole::ResetColor(bool stdout_stream)
|
||||
#endif
|
||||
}
|
||||
|
||||
void AppenderConsole::Print(std::string const& str, bool error)
|
||||
{
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
WriteWinConsole(str + "\n", error);
|
||||
#else
|
||||
utf8printf(error ? stderr : stdout, "%s\n", str.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
void AppenderConsole::_write(LogMessage const* message)
|
||||
{
|
||||
bool stdout_stream = !(message->level == LOG_LEVEL_ERROR || message->level == LOG_LEVEL_FATAL);
|
||||
@@ -194,9 +203,9 @@ void AppenderConsole::_write(LogMessage const* message)
|
||||
}
|
||||
|
||||
SetColor(stdout_stream, _colors[index]);
|
||||
utf8printf(stdout_stream ? stdout : stderr, "%s%s\n", message->prefix.c_str(), message->text.c_str());
|
||||
Print(message->prefix + message->text, !stdout_stream);
|
||||
ResetColor(stdout_stream);
|
||||
}
|
||||
else
|
||||
utf8printf(stdout_stream ? stdout : stderr, "%s%s\n", message->prefix.c_str(), message->text.c_str());
|
||||
Print(message->prefix + message->text, !stdout_stream);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user