mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
Introduce WindowsScopedCodePage
RAII class
This commit is contained in:
parent
5744db77b2
commit
ce7f41c01b
6 changed files with 28 additions and 0 deletions
|
@ -1315,6 +1315,7 @@ MAIN_FUNCTION
|
|||
#ifdef WIN32
|
||||
common::WinCmdLineArgs winArgs;
|
||||
std::tie(argc, argv) = winArgs.get();
|
||||
common::WindowsScopedCodePage windows_terminal_output_code_page{CP_UTF8};
|
||||
#endif
|
||||
SetupEnvironment();
|
||||
if (!SetupNetworking()) {
|
||||
|
|
|
@ -100,6 +100,7 @@ MAIN_FUNCTION
|
|||
#ifdef WIN32
|
||||
common::WinCmdLineArgs winArgs;
|
||||
std::tie(argc, argv) = winArgs.get();
|
||||
common::WindowsScopedCodePage windows_terminal_output_code_page{CP_UTF8};
|
||||
#endif
|
||||
|
||||
int exit_status;
|
||||
|
|
|
@ -257,6 +257,7 @@ MAIN_FUNCTION
|
|||
#ifdef WIN32
|
||||
common::WinCmdLineArgs winArgs;
|
||||
std::tie(argc, argv) = winArgs.get();
|
||||
common::WindowsScopedCodePage windows_terminal_output_code_page{CP_UTF8};
|
||||
#endif
|
||||
|
||||
NodeContext node;
|
||||
|
|
|
@ -889,5 +889,16 @@ std::pair<int, char**> WinCmdLineArgs::get()
|
|||
{
|
||||
return std::make_pair(argc, argv);
|
||||
}
|
||||
|
||||
WindowsScopedCodePage::WindowsScopedCodePage(UINT new_console_outp_code_page)
|
||||
: m_original_code_page{GetConsoleOutputCP()}
|
||||
{
|
||||
SetConsoleOutputCP(new_console_outp_code_page);
|
||||
}
|
||||
|
||||
WindowsScopedCodePage::~WindowsScopedCodePage()
|
||||
{
|
||||
SetConsoleOutputCP(m_original_code_page);
|
||||
}
|
||||
#endif
|
||||
} // namespace common
|
||||
|
|
|
@ -492,6 +492,19 @@ private:
|
|||
char** argv;
|
||||
std::vector<std::string> args;
|
||||
};
|
||||
|
||||
/**
|
||||
* A RAII-style class for temporarily changing the terminal output code page during runtime.
|
||||
*/
|
||||
class WindowsScopedCodePage
|
||||
{
|
||||
public:
|
||||
WindowsScopedCodePage(UINT new_console_outp_code_page);
|
||||
~WindowsScopedCodePage();
|
||||
|
||||
private:
|
||||
UINT m_original_code_page;
|
||||
};
|
||||
#endif
|
||||
} // namespace common
|
||||
|
||||
|
|
|
@ -481,6 +481,7 @@ int GuiMain(int argc, char* argv[])
|
|||
#ifdef WIN32
|
||||
common::WinCmdLineArgs winArgs;
|
||||
std::tie(argc, argv) = winArgs.get();
|
||||
common::WindowsScopedCodePage windows_terminal_output_code_page{CP_UTF8};
|
||||
#endif
|
||||
|
||||
std::unique_ptr<interfaces::Init> init = interfaces::MakeGuiInit(argc, argv);
|
||||
|
|
Loading…
Add table
Reference in a new issue