Ensure console output is UTF-8 under Windows
This commit is contained in:
parent
36246d3895
commit
89cb027786
|
@ -113,7 +113,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
|
|||
set(META_APP_DESCRIPTION "Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities")
|
||||
set(META_VERSION_MAJOR 4)
|
||||
set(META_VERSION_MINOR 3)
|
||||
set(META_VERSION_PATCH 0)
|
||||
set(META_VERSION_PATCH 1)
|
||||
|
||||
# find required 3rd party libraries
|
||||
include(3rdParty)
|
||||
|
|
|
@ -38,9 +38,8 @@ bool confirmPrompt(const char *message, Response defaultResponse)
|
|||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
/*!
|
||||
* \brief Starts the console.
|
||||
* \remarks This method is only available on Windows and used to start
|
||||
* a console from a GUI application.
|
||||
* \brief Starts the console and sets the console output code page to UTF-8.
|
||||
* \remarks This method is only available on Windows and used to start a console from a GUI application.
|
||||
*/
|
||||
void startConsole()
|
||||
{
|
||||
|
@ -68,6 +67,9 @@ void startConsole()
|
|||
fp = _fdopen(conHandle, "w");
|
||||
*stderr = *fp;
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
// set console to handle UTF-8 IO correctly
|
||||
SetConsoleCP(CP_UTF8);
|
||||
SetConsoleOutputCP(CP_UTF8);
|
||||
// sync
|
||||
ios::sync_with_stdio(true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue