mirror of https://github.com/axmolengine/axmol.git
Fix console output text encoding for win32.
This commit is contained in:
parent
99cdafb661
commit
026c3ab7c5
|
@ -158,10 +158,13 @@ void log(const char * format, ...)
|
|||
OutputDebugStringW(wbuf.c_str());
|
||||
|
||||
#if CC_LOG_TO_CONSOLE
|
||||
if (GetStdHandle(STD_INPUT_HANDLE)) {
|
||||
auto hStdout = ::GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (hStdout) {
|
||||
// print to console if possible
|
||||
wprintf(L"%s", wbuf.c_str());
|
||||
fflush(stdout);
|
||||
// since we use win32 API, the ::fflush call doesn't required.
|
||||
// see: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-flushfilebuffers#return-value
|
||||
DWORD wcch = static_cast<DWORD>(wbuf.size());
|
||||
::WriteConsoleW(hStdout, wbuf.c_str(), wcch, nullptr, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue