Multi-byte characters not rendered correctly when output from a C or C++ program
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 240
- Forks
- 60
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 1
Description
If a C or C++ program writes multi-byte characters to the console, they are not rendered correctly. The following shell script demonstrates the same.
#! /usr/bin/env sh
pacman -S --needed mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-python
printf '#include <stdio.h>\nint main(void) { puts("∈√≈≡⊥"); }\n' >msys2.c
gcc msys2.c
./a
echo $(./a)
printf '#include <cstdio>\nint main(void) { std::puts("∈√≈≡⊥"); }\n' >msys2.cc
g++ msys2.cc
./a
echo $(./a)
printf 'import sys\n\nprint("∈√≈≡⊥")' >msys2.py
python msys2.py
echo "∈√≈≡⊥"
Here's the output.
warning: mingw-w64-ucrt-x86_64-gcc-14.1.0-3 is up to date -- skipping
warning: mingw-w64-ucrt-x86_64-python-3.11.9-1 is up to date -- skipping
there is nothing to do
∈√≈≡⊥
∈√≈≡⊥
∈√≈≡⊥
∈√≈≡⊥
∈√≈≡⊥
∈√≈≡⊥
Key Observations
- When multi-byte characters are written by a C or C++ program, the actual characters written don't appear to be related, and can themselves by multi-byte.
- If the output is saved to a variable and then
echoed (seeecho $(./a)above), the characters are displayed correctly. - Upon writing multi-byte characters from Python or sh, nothing unexpected occurs.
I am using 64-bit MSYS2 20230526. I didn't try this with the latest version because I didn't find any bug reports for this issue even after searching for a while.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the shell script in the issue with the listed MSYS2 GCC, G++, and Python packages, comparing the C and C++ output with Python, sh, and command substitution. Trace the console handling for the C and C++ cases; done means the characters ∈√≈≡⊥ render correctly when written directly, while the existing comparison cases remain correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, shell
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100