CobaltFusion / DebugViewPP

DebugView++, collects, views, filters your application logs, and highlights information that is important to you!
Boost Software License 1.0
978 stars 144 forks source link

Unicode View Support For OutputDebugStringW #389

Open luodaoyi opened 9 months ago

luodaoyi commented 9 months ago

https://learn.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-waitfordebugeventex

https://learn.microsoft.com/zh-cn/windows/win32/api/debugapi/nf-debugapi-outputdebugstringw#remarks

OutputDebugStringW does internally call OutputDebugStringA, so Unicode characters that cannot be represented in the system code page will be replaced with ?.

Oddly enough, the OUTPUT_DEBUG_STRING_INFO structure the debugger receives from the operating system to print the message does appear to support letting the debugger know if the string is Unicode, it just doesn't appear to be used by OutputDebugStringW at all.

Unfortunately, I don't know of a mechanism to get the OS to raise a OUTPUT_DEBUG_STRING_EVENT with a Unicode string. It may not be possible with public APIs.

ref:

WaitForDebugEventEx function (debugapi.h)

windows - Is there a Unicode alternative to OutputDebugString? - Stack Overflow

janwilmans commented 9 months ago

I am not sure what the question is here? if you are looking for a way to send special characters, I suggest you try to use UTF-8 encoding through the OutputDebugStringA function? I think this how chinese users of debugview are doing it...

Later>> no sorry I was confusing two projects, debugviewpp has no UTF-8 support.

luodaoyi commented 9 months ago

Example:

Change setting to Japanese. or Korean language. Then call OutputDebugStringW("中文") with Chinese unicode charset.

In DebugView++ show: "????";

janwilmans commented 9 months ago

image

janwilmans commented 9 months ago

Please try changing the setting above, you can find it by searching for "Region" in the start menu, and send messages using OutputDebugStringW() and encoded as UCS-2 (windows own variant of UTF-16)

janwilmans commented 9 months ago

Example:

Change setting to Japanese. or Korean language. Then call OutputDebugStringW("中文") with Chinese unicode charset.

In DebugView++ show: "????";

You mean when the language in the OutputDebugStringW is different from the non-unicode programs setting in the Region dialog?

WebDancer69 commented 8 months ago

You mean when the language in the OutputDebugStringW is different from the non-unicode programs setting in the Region dialog?

Not necessarily the "language", but a lot of characters does not exist in the (limited) code page. Like e.g. Greek characters (in math) and emojis. Even if you try to avoid using "foreign" / "complex" characters in debug messages you often print project data, which can contain any Unicode glyph.

Later>> no sorry I was confusing two projects, debugviewpp has no UTF-8 support.

Are you sure DebugViewPP does not support it? It should support it if it supports other MBCS. image

janwilmans commented 4 months ago

well, debugview does not support UTF-8 natively, in code I assume everything is in UCS-2 but this windows feature might help, I am not sure. I will do some more testing. Let me know if you already found a solution?