Open Longhanks opened 1 year ago
I assume the C# extension might have had a similar issue: https://github.com/OmniSharp/omnisharp-vscode/issues/4398
But I was unable to find any commits concerning their fix, so I assume it was fixed within the closed-source components.
It has been a year, have you had any chance to reproduce the issue?
Environment
Bug Summary and Steps to Reproduce
When using "Start Debugging" or "Run Without Debugging" and the
launch.json
configuration"console": "internalConsole",
the Debug Console displaysstdout
(and with "Start Debugging", strings passed toOutputDebugString
-OutputDebugStringW
is unaffected by this issue: If a debugger is present (which can be checked viaIsDebuggerPresent()
), unicode passed as UTF-16 will be printed correctly).For the Debug Console,
stdout
is however always expected to convey bytes encoded in the active console input page, as retrieved withGetConsoleCP
.When running a program using "Run Without Debugging" and
"console": "internalConsole"
and printing strings to stdout, this is especially cumbersome: It is essentially impossible to print unicode characters that are not part of the code page that is returned byGetConsoleCP()
without modifying the console input code page. But also with the proper debugger (e. g. "Start Debugging"), strings printed tostdout
(notWriteConsole
orOutputDebugString
) are expected to be encoded in the active console input code page, which most probably does not support all unicode characters.This snippet demonstrates the steps necessary to get the unicode character
°
via stdout printed properly to the Debug Console:... which proves my assumption about the expected encoding of stdout.
A workaround is to call
SetConsoleCP(65001);
and printing UTF-8 tostdout
, but this has undesired side effects. Also, it is impossible to detect that the process is being redirected to "VS Code Debug Console", so the call would always have to be present, which I would also rather avoid, if possible.In my opinion, it would be great if it was possible to tell the "piping process" (whichever that is, e. g. closed source VS C++ debugger?) what encoding of stdout to expect.
Note that switching the client-side calls (
WriteFile
,printf
, orwprintf
) has no effect: It depends entirely on what bytes are written tostdout
.Debugger Configurations
Debugger Logs
Other Extensions
No response
Additional Information
Expected output in the Debug Console (reproducable in code page 850 with
0xF8 0x0A
):With
puts("°");
(e. g.0xc2 0xb0
):The biggest issue is essentially that when running using "Start Without Debugging", neither
WriteConsole
norOutputDebugString
work, thus, putting unicode outside of the current console input code page into the Debug Console is impossible without theSetConsoleCP
hack.