ConPTY not emitting OSC sequences longer than 256 characters (Windows 10) #20084

Open
opened 2026-01-31 07:02:59 +00:00 by claunia · 0 comments
Owner

Originally created by @segrey on GitHub (Jun 14, 2023).

Windows Terminal version

1.17.11461.0

Windows build number

10.0.19045.0

Other Software

No response

Steps to reproduce

You need Windows 10 to reproduce this. Not reproduced for me on Windows 11.

  1. Open forked GUIConsole.ConPTY. It runs the following PowerShell script under the hood:
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::Write("1")
[Console]::Write("$([char]0x1B)]42;$("a" * 5)`a")
[Console]::Write("2")
[Console]::Write("$([char]0x1B)]42;$("b" * 250)`a")
[Console]::Write("3")
[Console]::Write("$([char]0x1B)]42;$("c" * 251)`a")
[Console]::Write("4")
[Console]::Write("$([char]0x1B)]42;$("d" * 252)`a")
[Console]::Write("5")
[Console]::Write("$([char]0x1B)]42;$("e" * 253)`a")
  1. Run it in Windows Terminal. The following will be printed:
PS C:\Users\serge\sandbox\terminal\samples\ConPTY\GUIConsole\GUIConsole.ConPTY\bin\Debug\net7.0> .\GUIConsole.ConPTY.exe
Starting OSC-seq-example.ps1
stdout (length=356):
1dee2345
Found 7 sequences:
ESC[2J
ESC[m
ESC[H
ESC]0;C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe^G
ESC[?25h1
ESC]42;aaaaa^G
ESC]42;bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb^G^Gd^Gee^G2345

Expected Behavior

Visible printed text should be 12345.
The output should contain 5 OSC escape sequences:

  1. OSC 42 ; a x5
  2. OSC 42 ; b x250
  3. OSC 42 ; c x251
  4. OSC 42 ; d x252
  5. OSC 42 ; e x253

Actual Behavior

Instead, the visible printed text is 1dee2345.
The output contains only the first two escape sequnces:

  1. OSC 42 ; a x5
  2. OSC 42 ; b x250

Seems ConPTY cannot emit escape sequences longer than 256 characters. Are there any workarounds?

Originally created by @segrey on GitHub (Jun 14, 2023). ### Windows Terminal version 1.17.11461.0 ### Windows build number 10.0.19045.0 ### Other Software _No response_ ### Steps to reproduce You need Windows 10 to reproduce this. Not reproduced for me on Windows 11. 1. Open forked [GUIConsole.ConPTY](https://github.com/segrey/terminal/tree/OSC-seq-longer-256/samples/ConPTY/GUIConsole/GUIConsole.ConPTY). It runs the following PowerShell script under the hood: ``` [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 [Console]::Write("1") [Console]::Write("$([char]0x1B)]42;$("a" * 5)`a") [Console]::Write("2") [Console]::Write("$([char]0x1B)]42;$("b" * 250)`a") [Console]::Write("3") [Console]::Write("$([char]0x1B)]42;$("c" * 251)`a") [Console]::Write("4") [Console]::Write("$([char]0x1B)]42;$("d" * 252)`a") [Console]::Write("5") [Console]::Write("$([char]0x1B)]42;$("e" * 253)`a") ``` 2. Run it in Windows Terminal. The following will be printed: ``` PS C:\Users\serge\sandbox\terminal\samples\ConPTY\GUIConsole\GUIConsole.ConPTY\bin\Debug\net7.0> .\GUIConsole.ConPTY.exe Starting OSC-seq-example.ps1 stdout (length=356): 1dee2345 Found 7 sequences: ESC[2J ESC[m ESC[H ESC]0;C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe^G ESC[?25h1 ESC]42;aaaaa^G ESC]42;bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb^G^Gd^Gee^G2345 ``` ### Expected Behavior Visible printed text should be `12345`. The output should contain 5 OSC escape sequences: 1. OSC 42 ; `a` x5 2. OSC 42 ; `b` x250 3. OSC 42 ; `c` x251 4. OSC 42 ; `d` x252 5. OSC 42 ; `e` x253 ### Actual Behavior Instead, the visible printed text is `1dee2345`. The output contains only the first two escape sequnces: 1. OSC 42 ; `a` x5 2. OSC 42 ; `b` x250 Seems ConPTY cannot emit escape sequences longer than 256 characters. Are there any workarounds?
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 07:03:00 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20084