Repository navigation
Description
I noticed #389 was closed, but with a specific direction: trying to translate to UTF-8 and VERY experimental UTF-8 OS support. There was also talk about making DebugViewPP's codepage UTF-8 by default.
In the issue you write You can see that 日本語 passed through OutputDebugStringW is literally translated into a call OutputDebugStringA("???"); by windows. However I CAN'T see that; I see two calls, and two recordings of those calls in DebugViewPP. I see no evidence of an additional/intermediate call to OutputDebugStringA. But I didn't check any DebugViewPP code paths here.
void EncodingTest()
{
const wchar_t* utf16Message = L"This message is UTF-16 encoded and send through OutputDebugStringW \u65E5\u672C\u8A9E"; // 日本語 UTF-16 encoded
OutputDebugStringW(utf16Message);
// 日本語 😀" encoded as UTF-8 bytes
const char* utf8Message = "This message is UTF-8 encoded and send through OutputDebugStringA (with special windows settings): "
"\xE6\x97\xA5" // 日 // Ni
"\xE6\x9C\xAC" // 本 // Hon
"\xE8\xAA\x9E" // 語 // Go
" "
"\xF0\x9F\x98\x80"; // 😀
OutputDebugStringA(utf8Message);
}
The API documentation is a bit ambiguous here:
https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-outputdebugstringw
"To force OutputDebugStringW to return Unicode strings, debuggers are required to call the WaitForDebugEventEx function to opt into the new behavior."
and
"OutputDebugStringW converts the specified string based on the current system locale information and passes it to OutputDebugStringA to be displayed. As a result, some Unicode characters may not be displayed correctly."
The second remark seems to suggest Windows always does a translation via OutputDebugStringA, BUT the first remarks strongly suggests it will properly send UTF-16 chars if the application uses WaitForDebugEventEx instead.
Furthermore, https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-waitfordebugeventex has:
"Important In the past, the operating system did not output Unicode strings via OutputDebugStringW and instead only output ASCII strings. To force OutputDebugStringW to correctly output Unicode strings, debuggers are required to call WaitForDebugEventEx to opt into the new behavior. On calling WaitForDebugEventEx, the operating system will know that the debugger supports Unicode and is specifically opting into receiving Unicode strings."
and
typedef struct _OUTPUT_DEBUG_STRING_INFO {
LPSTR lpDebugStringData;
WORD fUnicode;
WORD nDebugStringLength;
} OUTPUT_DEBUG_STRING_INFO, *LPOUTPUT_DEBUG_STRING_INFO;
"fUnicode
The format of the debugging string. If this member is zero, the debugging string is ANSI; if it is nonzero, the string is Unicode."
Unicode. As we're reading from the target process address space, shouldn't this be the same Unicode string it writes with OutputDebugStringW?
I would really appreciate to be able to send full UTF-16 Unicode strings regardless of OS code page settings, using OutputDebugStringW. It would help tremendously with debugging UTF-16 Unicode enabled applications. Could you please investigate if this is still possible in principle?
Activity
janwilmans commentedon Oct 17, 2026
please re-test this on your machine, it should be fixed in v1.21 and up.
nomennescio commentedon Nov 17, 2026
Hi Jan, I tested this with the following code
Compile into ods.exe, then run from a commandline:
The output does show up DebugView++, however not as UTF16. It does show up correctly in the MessageBox, hence the
cmdlineparameter itself is correctly handled.DebugView++ output:

Messagebox output:
nomennescio commentedon Nov 17, 2026
This was with v1.31.0.0
Strangely enough, it showed an exit procedure line that HAS the correct output taking it from the invocation:
nomennescio commentedon Nov 17, 2026
After chasing down the merged code, I was able to make it work; to have a resource file with embedded manifest that sets the codepage of the active process (!) to UTF8 (only supported since late versions of Windows 10). For those who run into this, I've used
<file.rc>:Compile and link this into your executable that wants to send using
OutputDebugStringW. To be honest, this a completely broken design on the part of Windows.janwilmans commentedon Nov 17, 2026
for a program you control, sending UTF-8 with OutputDebugStringA is the simplest route. It needs no manifest and doesn’t depend on any code page setting, in the sender or in DebugViewPP. You only need the manifest trick from @nomennescio 's comment if the program has to keep using OutputDebugStringW.
janwilmans commentedon Nov 17, 2026
@nomennescio thanks for that clarification!
nomennescio commentedon Nov 18, 2026
Do you know if that is supported in older Windows versions?
WebDancer69 commentedon Nov 19, 2026
There seems to be some confusion around UTF-16 support and
WaitForDebugEventEx(). When usingOutputDebugStringW()with no debugger attached, but using a listener to the "legacy" shared buffer which e.g. DebugView++ is using, the strings are always converted to ANSI when sent from the client process, using the codepage of the client process. UsingWaitForDebugEventEx()to get full UTF-16 support withOutputDebugStringW()only works when the logger attaches as a debugger, which uses a completely different mechanism to transfer the strings.One solution that works is to set the system code page to UTF-8, if both the client app and DebugView++ is using the default codepage. The conversion between UTF-8 ("ANSI") and UTF-16 ("Unicode") can handle all characters. But setting UTF-8 globally may not be a good option with some (legacy) programs.
A preferred solution is to only set UTF-8 explicitly on your client app. But then you depend on DebugView++ also decoding the sent buffer as UTF-8. You also have the issue where
<activeCodePage>now can select other codepages in recent Windows versions.The full solution could then be:
DebugView++ is set to always be UTF-8 internally with
<activeCodePage>, and (if needed) convert incoming strings to UTF-8 before using them.Getting the client / source codepage can be tricky. The default should be to use the system code page. The actual codepage a process is using can be read from the process PEB, but this is undocumented and possibly unstable, in addition access will not be allowed for all processes. Using configurable codepage settings in DebugView++ for given process names is probably the best solution.
(From what I can find: UTF-8 codepage has been available as a system codepage since Windows 10 1803, and in
<activeCodePage>since Windows 10 1903. Support for non-UTF-8 code pages in<activeCodePage>was added in Windows 11 21H2. )