Unable to pasteC1 control characters #15285

Closed
opened 2026-01-31 04:33:45 +00:00 by claunia · 7 comments
Owner

Originally created by @NightFurySL2001 on GitHub (Sep 20, 2021).

Windows Terminal version (or Windows build number)

Microsoft Windows [Version 10.0.19043.1237]

Other Software

No response

Steps to reproduce

Copy and paste the following text:

A9§9

Additional steps: run py and then copy paste the following:

"A9§9".encode("latin1").decode("gb18030")

There should be one control character (U+0081) between A and 9.

Expected Behavior

A missing character (U+0081) should appear in between æ and 9 which appeared in Command Prompt and Windows PowerShell. Running the Python command should output A・ (A followed by U+30FB).

image

image

Actual Behavior

The C1 control character did not get pasted and resulted in error.

image

Originally created by @NightFurySL2001 on GitHub (Sep 20, 2021). ### Windows Terminal version (or Windows build number) Microsoft Windows [Version 10.0.19043.1237] ### Other Software _No response_ ### Steps to reproduce Copy and paste the following text: ``` A9§9 ``` Additional steps: run `py` and then copy paste the following: ``` "A9§9".encode("latin1").decode("gb18030") ``` There should be one control character (U+0081) between `A` and `9`. ### Expected Behavior A missing character (U+0081) should appear in between `æ` and `9` which appeared in Command Prompt and Windows PowerShell. Running the Python command should output `A・` (A followed by U+30FB). ![image](https://user-images.githubusercontent.com/33471049/134027920-fdf3570b-b1ad-4048-b0c9-fd3c0f221408.png) ![image](https://user-images.githubusercontent.com/33471049/134028030-1476ff45-89a1-4434-9372-04115b153ac5.png) ### Actual Behavior The C1 control character did not get pasted and resulted in error. ![image](https://user-images.githubusercontent.com/33471049/134028250-827b939e-1c21-4398-8f6c-f5d52d545780.png)
claunia added the Resolution-By-DesignNeeds-Tag-Fix labels 2026-01-31 04:33:45 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Sep 20, 2021):

What happens if you run chcp 65001 before running python?

@zadjii-msft commented on GitHub (Sep 20, 2021): What happens if you run `chcp 65001` before running python?
Author
Owner

@NightFurySL2001 commented on GitHub (Sep 20, 2021):

I'm on 65001. The problem stems from pasting the string into Terminal, not with Python.

Edit: There should have been one U+0081 between the A and 9. GitHub doesn't display it correctly but it did stored correctly in Markdown.

@NightFurySL2001 commented on GitHub (Sep 20, 2021): I'm on 65001. The problem stems from pasting the string into Terminal, not with Python. Edit: There should have been one U+0081 between the `A` and `9`. GitHub doesn't display it correctly but it did stored correctly in Markdown.
Author
Owner

@DHowett commented on GitHub (Sep 20, 2021):

So, Terminal operates under the assumption that the text on the clipboard is well-formed UTF-16 and strips all C0 and C1 controls from it, by design.

What compelling use case do you have for pasting U+0081 that wouldn't be resolved by including \x81 or \u0081 in the text from which you're copying? It is arguably more correct and safer for transit.

@DHowett commented on GitHub (Sep 20, 2021): So, Terminal operates under the assumption that the text on the clipboard is well-formed UTF-16 and strips all C0 and C1 controls from it, by design. What compelling use case do you have for pasting `U+0081` that wouldn't be resolved by including `\x81` or `\u0081` in the text from which you're copying? It is arguably more correct and safer for transit.
Author
Owner

@ghost commented on GitHub (Sep 24, 2021):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@ghost commented on GitHub (Sep 24, 2021): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@NightFurySL2001 commented on GitHub (Sep 27, 2021):

I copied the text from a program that was spitting error code and messing around with the text. I am not sure if it counts as a reasonable use case but this behaviour is significantly different from Command Prompt and Windows Powershell.

@NightFurySL2001 commented on GitHub (Sep 27, 2021): I copied the text from a program that was spitting error code and messing around with the text. I am not sure if it counts as a reasonable use case but this behaviour is significantly different from Command Prompt and Windows Powershell.
Author
Owner

@oniony commented on GitHub (Nov 12, 2021):

I hit this same problem. I had a telnet session with Redis (in Powershell in Windows Terminal), went to paste a compound key that is separated with the Unit Separator character (0x1f) and the control character gets stripped from the pasted text.

If I do the same thing from cmd.exe or powershell.exe it pastes just fine.

Pasting the equivalent of abc␟def becomes abcdef. (I can't put the actual character in this comment as GitHub replaces it with a different character.)

I get same behaviour if I paste into Ubuntu (WSL2) or Git Bash running in Windows Terminal too.

(Windows Terminal Preview 1.11.2421.0)

@oniony commented on GitHub (Nov 12, 2021): I hit this same problem. I had a telnet session with Redis (in Powershell in Windows Terminal), went to paste a compound key that is separated with the Unit Separator character (`0x1f`) and the control character gets stripped from the pasted text. If I do the same thing from `cmd.exe` or `powershell.exe` it pastes just fine. Pasting the equivalent of `abc␟def` becomes `abcdef`. (I can't put the actual character in this comment as GitHub replaces it with a different character.) I get same behaviour if I paste into Ubuntu (WSL2) or Git Bash running in Windows Terminal too. (Windows Terminal Preview 1.11.2421.0)
Author
Owner

@carlos-zamora commented on GitHub (Dec 14, 2022):

Hi @NightFurySL2001. We talked about this as a team today. As @DHowett mentioned earlier, we strip C0 and C1 control sequences be design for security reasons. Though Command Prompt and Windows Powershell (via ConHost) still support this scenario, we've decided that we do not want to support this feature in Windows Terminal moving forward.

Closing as by design. Thanks for your patience.

@carlos-zamora commented on GitHub (Dec 14, 2022): Hi @NightFurySL2001. We talked about this as a team today. As @DHowett mentioned earlier, we strip C0 and C1 control sequences be design for security reasons. Though Command Prompt and Windows Powershell (via ConHost) still support this scenario, we've decided that we do not want to support this feature in Windows Terminal moving forward. Closing as by design. Thanks for your patience.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15285