I have C code that prints some characters. I would like to see these characters printed, as opposed to an alphabet soup,
#include <stdio.h>
int main() {
const char* test = "Greek: αβγδ; German: Übergrößenträger";
printf("%s\n", test);
}
What works:
- Native Linux compilation:
gcc test.c -o test && ./test
- Winegcc compilation:
winegcc test.c o test.exe && ./test.exe
- MinGW64 compilation when the output is not a terminal :
x86_64-w64-mingw32-gcc -o test.exe test.cpp && wine ./test.exe | cat
All three commands print Greek: αβγδ; German: Übergrößenträger
to the terminal.
What doesn't work:
- MinGW64 compilation when the output is a terminal:
x86_64-w64-mingw32-gcc -o test.exe test.cpp && wine ./test.exe
This prints Greek: αβγδ; German: ÃbergröÃenträger
to the terminal.
It looks like the MinGW runtime detects if the output is a terminal/console, and does exactly the wrong thing.
What I have tried:
system("chcp 65001");
— same output (the chcp command succeeds).x86_64-w64-mingw32-gcc -fexec-charset=utf8 -finput-charset=utf8
— same output.SetConsoleOutputCP(CP_UTF8);
— same output.wineconsole cmd
and run.\test
from there — same output.LANG=en_US.UTF-8 wine ./test.exe
— same output._setmode(_fileno(stdout), _O_U8TEXT);
— no output at all.- Most combinations of the above — no dice.
What I have not tried yet:
- Compiling with a Microsoft compiler under Wine.
- Compiling with MinGW under Wine.
- Compiling and/or running the program under real Windows with either compiler.
How can I fix the non-working case?