I was trying to use debugView in Electron for some reason
When I use OutputDebugStringW everything I send to output become random char, on the other hand it seems correct when sending output using OutputDebugStringA contains English and number is normal
this is what it looks like using both functions
DebugView preview
I've found something on this site, however it seems not having much information in it.
What is the main different between these two function in Kernel32.dll
And when should I use which one of them
Thanks in advance
CodePudding user response:
Why does misdetected Unicode text tend to show up as Chinese characters?
The OutputDebugStringA
function takes a narrow string as input. 8 bits per code unit, encoded with the active codepage of the system.
The OutputDebugStringW
function takes a UTF-16LE string as input (2 bytes per code unit).
Most functions on Windows that deals with strings exist as A and W versions. Usually the A version converts the string and calls the W version internally. Applications that are Unicode enabled/aware should call the W function.
If your strings are UTF-8, you should convert them to UTF-16LE and call the W function unless you know for sure that you are on Windows 10 (1903) or higher and you have enabled UTF-8 as the codepage in the application manifest. If all of those things are true then you may call the A version directly instead.
Older applications designed for Windows 95/98 call the A functions but with a legacy codepage, not UTF-8.