aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-08-25 16:55:14 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-08-25 17:30:56 -0700
commit67b9475ef29496508640f73410a10ecf737389eb (patch)
tree4cfb67d1efa0528871a4d4c2a9b9589231f5e54e /toolsrc/src
parentaf017922974c4612517fe9c512df7cdd1ac79b43 (diff)
downloadvcpkg-67b9475ef29496508640f73410a10ecf737389eb.tar.gz
vcpkg-67b9475ef29496508640f73410a10ecf737389eb.zip
[vcpkg] Set codepage to 65001, duplicate of #1682, fixes #1660 #1631 #1644
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg.cpp36
-rw-r--r--toolsrc/src/vcpkg_Checks.cpp3
-rw-r--r--toolsrc/src/vcpkg_GlobalState.cpp3
3 files changed, 12 insertions, 30 deletions
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index fc9b1a016..f37d079a6 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -18,30 +18,6 @@
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);
@@ -216,13 +192,13 @@ 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::g_init_console_cp = GetConsoleCP();
+ GlobalState::g_init_console_output_cp = GetConsoleOutputCP();
- *GlobalState::timer.lock() = ElapsedTime::create_started();
+ SetConsoleCP(65001);
+ SetConsoleOutputCP(65001);
- // Checks::register_console_ctrl_handler();
+ *GlobalState::timer.lock() = ElapsedTime::create_started();
const std::string trimmed_command_line = trim_path_from_command_line(Strings::to_utf8(GetCommandLineW()));
@@ -240,7 +216,7 @@ int wmain(const int argc, const wchar_t* const* const argv)
if (auto p = args.sendmetrics.get()) Metrics::g_metrics.lock()->set_send_metrics(*p);
if (auto p = args.debug.get()) GlobalState::debugging = *p;
- vcpkg::Checks::register_console_ctrl_handler();
+ Checks::register_console_ctrl_handler();
if (GlobalState::debugging)
{
diff --git a/toolsrc/src/vcpkg_Checks.cpp b/toolsrc/src/vcpkg_Checks.cpp
index d8d857daa..2ad2d06ab 100644
--- a/toolsrc/src/vcpkg_Checks.cpp
+++ b/toolsrc/src/vcpkg_Checks.cpp
@@ -17,6 +17,9 @@ namespace vcpkg::Checks
GlobalState::debugging = false;
metrics->flush();
+ SetConsoleCP(GlobalState::g_init_console_cp);
+ SetConsoleOutputCP(GlobalState::g_init_console_output_cp);
+
::exit(exit_code);
}
diff --git a/toolsrc/src/vcpkg_GlobalState.cpp b/toolsrc/src/vcpkg_GlobalState.cpp
index c194da466..2221222c0 100644
--- a/toolsrc/src/vcpkg_GlobalState.cpp
+++ b/toolsrc/src/vcpkg_GlobalState.cpp
@@ -7,4 +7,7 @@ namespace vcpkg
Util::LockGuarded<ElapsedTime> GlobalState::timer;
std::atomic<bool> GlobalState::debugging = false;
std::atomic<bool> GlobalState::feature_packages = false;
+
+ std::atomic<int> GlobalState::g_init_console_cp = 0;
+ std::atomic<int> GlobalState::g_init_console_output_cp = 0;
}