From 6c762ec72ea4b0aa1f0da285ce01d8d93cba1979 Mon Sep 17 00:00:00 2001 From: Karlson2k Date: Fri, 17 Aug 2012 14:34:40 +0400 Subject: [PATCH] [win32] Fix incorrect debug output on non-ASCII system --- xbmc/utils/log.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xbmc/utils/log.cpp b/xbmc/utils/log.cpp index f787c4b8f75ff..674140e1aa89e 100644 --- a/xbmc/utils/log.cpp +++ b/xbmc/utils/log.cpp @@ -213,7 +213,18 @@ int CLog::GetLogLevel() void CLog::OutputDebugString(const std::string& line) { #if defined(_DEBUG) || defined(PROFILE) - ::OutputDebugString(line.c_str()); +#if defined(TARGET_WINDOWS) + // we can't use charsetconverter here as it's initialized later than CLog and deinitialized early + int bufSize = MultiByteToWideChar(CP_UTF8, 0, line.c_str(), -1, NULL, 0); + CStdStringW wstr (L"", bufSize); + if ( MultiByteToWideChar(CP_UTF8, 0, line.c_str(), -1, wstr.GetBuf(bufSize), bufSize) == bufSize ) + { + wstr.RelBuf(); + ::OutputDebugStringW(wstr.c_str()); + } + else +#endif // TARGET_WINDOWS + ::OutputDebugString(line.c_str()); ::OutputDebugString("\n"); #endif }