Terminal Apps don't enter UTF8 mode properly
When launching a Text-UI terminal app that uses UTF8 emojis and special characters, the special characters all render as the tofu character.
In Windows you typically have to enable utf8 mode for terminals explicitly, which the program I was attempting to debug does. I wonder if raddbg is somehow interfering with this?
One possible approach might be to allow users to specify which terminal they'd like their app to open in (Powershell/Windows Terminal/etc).
Might be related to #621
I'm happy to give more detailed info if you need it, but it should be pretty easily reproducible
This should not be affected by debugger in any way. Not sure what you mean by "powershell" here, because powershell is not a terminal, it's a shell. When you run your program under debugger it just launches native process on your .exe. There's no shell involved - no cmd.exe or powershell.exe is running.
If you just want to switch between old conhost vs new wt terminals, then you can do that in Windows settings - System -> Advanced -> Terminal. raddbg will just launch whichever terminal is set there (technically Windows does that for us).
Here's example code that I tried to print out emoji's with old console utf16 api and in newer way of setting utf8 code explicitly, and it works for me just fine:
conhost:
wt:
code:
#include <windows.h>
int main()
{
HANDLE stdout = GetStdHandle(STD_OUTPUT_HANDLE);
WCHAR emoji_utf16[] = {
L"\xD83D\xDE0A\x2764\xFE0F\xD83D\xDE02\xD83D"
L"\xDC4D\xD83E\xDD23\xD83D\xDC4C\xD83D\xDE01\n"
};
WriteConsoleW(stdout, emoji_utf16, ARRAYSIZE(emoji_utf16), NULL, NULL);
SetConsoleOutputCP(CP_UTF8);
char emoji_utf8[] = {
"\xF0\x9F\x98\x8A\xE2\x9D\xA4\xEF\xB8\x8F"
"\xF0\x9F\x98\x82\xF0\x9F\x91\x8D\xF0\x9F"
"\xA4\xA3\xF0\x9F\x91\x8C\xF0\x9F\x98\x81\n"
};
DWORD written;
WriteFile(stdout, emoji_utf8, ARRAYSIZE(emoji_utf8), &written, NULL);
return 0;
}
I will try to create a reproduce case this weekend, and close this if I can't.
ok on my system, with your sample code I get
I built bug.exe with gcc -g -o bug .\bug.c
I launched raddbg with PS C:\Users\tenari\Documents\projects\wizduel> ~/Downloads/raddbg .\bug.exe
my Windows terminal settings were
When I changed to
then the utf8 sample program worked
So it does seem like this is not a raddbg-specific issue
Which seems confirmed when I manually open conhost and run the sample program...
sorry about this.