Added code page setting for the console window

This commit is contained in:
NovaRain
2023-06-15 23:27:07 +08:00
parent b8c52304eb
commit f9dc7a3e25
2 changed files with 7 additions and 0 deletions
+3
View File
@@ -906,3 +906,6 @@ ConsoleWindow=0
;Console window position and size data. Do not modify
ConsoleWindowData=
;Set the code page for the console window (Default is your system code page)
ConsoleCodePage=0
+4
View File
@@ -46,6 +46,7 @@ public:
static constexpr char* IniSection = "Debugging";
static constexpr char* IniModeKey = "ConsoleWindow";
static constexpr char* IniPositionKey = "ConsoleWindowData";
static constexpr char* IniCodePageKey = "ConsoleCodePage";
static ConsoleWindow& instance() { return _instance; }
@@ -137,6 +138,9 @@ void ConsoleWindow::init() {
dlog_f("Failed to allocate console: 0x%x\n", DL_MAIN, GetLastError());
return;
}
int cp = IniReader::GetIntDefaultConfig(IniSection, IniCodePageKey, 0);
if (cp > 0) SetConsoleOutputCP(cp);
freopen("CONOUT$", "w", stdout); // this allows to print to console via std::cout
if (_mode & ConsoleSource::GAME) {