[WSL]: Chinese input can't be deleted as expected. #21076

Closed
opened 2026-01-31 07:32:29 +00:00 by claunia · 4 comments
Owner

Originally created by @foldl on GitHub (Jan 8, 2024).

Windows Terminal version

1.18.3181.0

Windows build number

10.0.22635.2921

Other Software

WSL.

Steps to reproduce

  1. Build this simple C++ program (bug.cpp) with g++ bug.cpp:

    #include <string>
    #include <iostream>
    int main(int argc, const char **argv)
    {
        std::string s;
        std::cin >> s;
        std::cout << s << std::endl;
        return 0;
    }
    
  2. Run it with ./a.out, input some Chinese characters, such as "时间",
    and we see that this string is eched correctly.

  3. Run it again, input "时间", then use Backspace to delete one or two characters, we can see GUI's behaviour is wrong.

    As shown in the image, I have presse Backspace several times, but "时" is always there. Then I typed in "世界"
    and 3 characters ("时世界") is displayed. Press Enter, we see that "世界" is echoed correctly.

image

Expected Behavior

Chinese input can be deleted as expected.

Actual Behavior

Some Chinese characters are displayed even through they are already deleted.

Originally created by @foldl on GitHub (Jan 8, 2024). ### Windows Terminal version 1.18.3181.0 ### Windows build number 10.0.22635.2921 ### Other Software WSL. ### Steps to reproduce 1. Build this simple C++ program (bug.cpp) with `g++ bug.cpp`: ```c++ #include <string> #include <iostream> int main(int argc, const char **argv) { std::string s; std::cin >> s; std::cout << s << std::endl; return 0; } ``` 1. Run it with `./a.out`, input some Chinese characters, such as "时间", and we see that this string is eched correctly. 1. Run it again, input "时间", then use Backspace to delete one or two characters, we can see GUI's behaviour is wrong. As shown in the image, I have presse Backspace several times, but "时" is always there. Then I typed in "世界" and 3 characters ("时世界") is displayed. Press Enter, we see that "世界" is echoed correctly. ![image](https://github.com/microsoft/terminal/assets/4046440/8c15f742-bbe8-4cf3-a0ad-5ede76973722) ### Expected Behavior Chinese input can be deleted as expected. ### Actual Behavior Some Chinese characters are displayed even through they are already deleted.
claunia added the Needs-TriageIssue-BugNeeds-Attention labels 2026-01-31 07:32:29 +00:00
Author
Owner

@lhecker commented on GitHub (Jan 8, 2024):

Hmm I don't think that's a bug in our code. What's the output when you run stty -a | grep -o '.iutf8'? If it has a - at the start, can you try running your test after executing stty iutf8?

Also, when you make such input modifications it may be that the cursor is incorrectly positioned. I think this may be a flaw in how we handle backspaces... Currently we treat backspaces as "place cursor 1 column to the left" but it seems like libstdc++ assumes that a backspace moves by 2 columns when a wide glyph is encountered. Or maybe it doesn't handle wide glyphs at all? Gnome Terminal handles backspace identical to how we do it.

@lhecker commented on GitHub (Jan 8, 2024): Hmm I don't think that's a bug in our code. What's the output when you run `stty -a | grep -o '.iutf8'`? If it has a `-` at the start, can you try running your test after executing `stty iutf8`? Also, when you make such input modifications it may be that the cursor is incorrectly positioned. I think this may be a flaw in how we handle backspaces... Currently we treat backspaces as "place cursor 1 column to the left" but it seems like libstdc++ assumes that a backspace moves by 2 columns when a wide glyph is encountered. Or maybe it doesn't handle wide glyphs at all? Gnome Terminal handles backspace identical to how we do it.
Author
Owner

@foldl commented on GitHub (Jan 9, 2024):

This is not a bug in Terminal. I tested it on Linux Mint 21 in a Virtual Machine, and the behavior is just the same.

I will close this issue.

By the way, output of stty -a | grep -o '.iutf8' is iutf8.

@foldl commented on GitHub (Jan 9, 2024): This is not a bug in Terminal. I tested it on Linux Mint 21 in a Virtual Machine, and the behavior is just the same. I will close this issue. By the way, output of `stty -a | grep -o '.iutf8'` is `iutf8`.
Author
Owner

@foldl commented on GitHub (Jan 9, 2024):

FYI: I resolved it by using this:

https://github.com/hanslub42/rlwrap

@foldl commented on GitHub (Jan 9, 2024): FYI: I resolved it by using this: https://github.com/hanslub42/rlwrap
Author
Owner

@lhecker commented on GitHub (Jan 9, 2024):

Thanks for letting us know!

@lhecker commented on GitHub (Jan 9, 2024): Thanks for letting us know!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21076