mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
update: fwprintf for wchar_t handling. Cleaned up old debug impl
This commit is contained in:
parent
5dd67bd334
commit
5d5cd69a5e
|
|
@ -651,23 +651,6 @@ static inline BOOL QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _FINAL_BUILD
|
|
||||||
VOID OutputDebugStringW(LPCWSTR lpOutputString)
|
|
||||||
{
|
|
||||||
fwprintf(stderr, lpOutputString);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID OutputDebugString(LPCSTR lpOutputString)
|
|
||||||
{
|
|
||||||
fprintf(stderr, lpOutputString);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID OutputDebugStringA(LPCSTR lpOutputString)
|
|
||||||
{
|
|
||||||
fprintf(stderr, lpOutputString);
|
|
||||||
}
|
|
||||||
#endif // _CONTENT_PACKAGE
|
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringa
|
// https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringa
|
||||||
static inline VOID OutputDebugStringA(LPCSTR lpOutputString)
|
static inline VOID OutputDebugStringA(LPCSTR lpOutputString)
|
||||||
{
|
{
|
||||||
|
|
@ -679,15 +662,7 @@ static inline VOID OutputDebugStringA(LPCSTR lpOutputString)
|
||||||
static inline VOID OutputDebugStringW(LPCWSTR lpOutputString)
|
static inline VOID OutputDebugStringW(LPCWSTR lpOutputString)
|
||||||
{
|
{
|
||||||
if (!lpOutputString) return;
|
if (!lpOutputString) return;
|
||||||
// wchar_t* -> char* via wcstombs, respecting the current locale.
|
fprintf(stderr, "%ls", lpOutputString);
|
||||||
// Passing NULL as dst to wcstombs queries the required buffer length.
|
|
||||||
size_t len = wcstombs(NULL, lpOutputString, 0);
|
|
||||||
if (len == (size_t)-1) return; // unconvertible sequence
|
|
||||||
char *buf = (char *)malloc(len + 1);
|
|
||||||
if (!buf) return;
|
|
||||||
wcstombs(buf, lpOutputString, len + 1);
|
|
||||||
fputs(buf, stderr);
|
|
||||||
free(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline VOID OutputDebugString(LPCSTR lpOutputString)
|
static inline VOID OutputDebugString(LPCSTR lpOutputString)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue