crossterm
crossterm copied to clipboard
Surrogate pairs are ignored on Windows Terminal
Describe the bug
On Windows Terminal, characters represented by UTF-16 surrogate pairs are not decoded properly and are ignored.
To Reproduce
- Run the code https://gist.github.com/kazatsuyu/d112afeebac0490efac267bbf2355f84 on Windows terminal.
- Copy and paste
"abc🐈def". - Confirm that the 🐈 is not displayed.
Expected behavior
The 🐈 is displayed.
OS
Windows 11 22621.2428
Terminal/Console
Windows Terminal
I made a small modification to crossterm_winapi to allow it to display low-level input events.
Windows Terminal seems to send two input events for surrogate pairs, one with key_down: true and one with key_down: false.
When input from the console displayed by AllocConsole, only the one with key_down: false is sent.
If one of consecutive upper surrogates and the lower surrogate in the absence of an upper surrogate were ignored, it would be possible to handle this kind of input pattern.