[vcpkg] use for console input/output
MODIFY
src/vcpkg.cpp
src/vcpkg.cpp
using namespace vcpkg;
+UINT console_cp_input;
+UINT console_cp_output;
+
+void console_cp_set()
+{
+ console_cp_input = GetConsoleCP();
+ console_cp_output = GetConsoleOutputCP();
+
+ SetConsoleCP(CP_UTF8);
+ SetConsoleOutputCP(CP_UTF8);
+}
+
+void console_cp_reset()
+{
+ SetConsoleCP(console_cp_input);
+ SetConsoleOutputCP(console_cp_output);
+}
+
+BOOL console_ctrl_handler(DWORD fdwCtrlType)
+{
+ console_cp_reset();
+ return TRUE;
+}
+
void invalid_command(const std::string& cmd)
{
System::println(System::Color::error, "invalid command: %s", cmd);
@@ -192,6 +216,10 @@ int wmain(const int argc, const wchar_t* const* const argv)
{
if (argc == 0) std::abort();
+ console_cp_set();
+ SetConsoleCtrlHandler(PHANDLER_ROUTINE(console_ctrl_handler), TRUE);
+ atexit(console_cp_reset);
+
*GlobalState::timer.lock() = ElapsedTime::create_started();
// Checks::register_console_ctrl_handler();

[vcpkg] use UTF-8 for console input/output