mirror of
https://github.com/OpenMW/openmw.git
synced 2026-02-01 03:48:27 +00:00
parent
6b3a3418c2
commit
c1f9bd2931
1 changed files with 10 additions and 7 deletions
|
|
@ -173,10 +173,7 @@ namespace Debug
|
|||
return All;
|
||||
}
|
||||
|
||||
virtual std::streamsize writeImpl(const char* str, std::streamsize size, Level debugLevel)
|
||||
{
|
||||
return size;
|
||||
}
|
||||
virtual std::streamsize writeImpl(const char* str, std::streamsize size, Level debugLevel) { return size; }
|
||||
};
|
||||
|
||||
#if defined _WIN32 && defined _DEBUG
|
||||
|
|
@ -185,10 +182,16 @@ namespace Debug
|
|||
public:
|
||||
std::streamsize writeImpl(const char* str, std::streamsize size, Level debugLevel)
|
||||
{
|
||||
// Make a copy for null termination
|
||||
std::string tmp(str, static_cast<unsigned int>(size));
|
||||
if (size > std::numeric_limits<int>::max())
|
||||
OutputDebugStringW(L"Next line truncated...");
|
||||
auto wideSize = MultiByteToWideChar(CP_UTF8, 0, str,
|
||||
static_cast<int>(std::min<std::streamsize>(size, std::numeric_limits<int>::max())), nullptr, 0);
|
||||
std::wstring wide(wideSize, L'\0');
|
||||
MultiByteToWideChar(CP_UTF8, 0, str,
|
||||
static_cast<int>(std::min<std::streamsize>(size, std::numeric_limits<int>::max())), wide.data(),
|
||||
wideSize);
|
||||
// Write string to Visual Studio Debug output
|
||||
OutputDebugString(tmp.c_str());
|
||||
OutputDebugStringW(wide.c_str());
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue