question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird string value written to the standard output

See original GitHub issue

Unwanted std out side effect on window resize The library (or one of its dependencies?) seems to write the string value “\u001b[3J” to the standard output under certain circumstances. As a result, if one has decided to redirect the standard output to some UI component, such as a TextView, they see this weird string value the first time the application starts and whenever the window size changes.

To Reproduce Steps to reproduce the behavior:

  1. Create a console GUI app with a multiline text view (the component and its multiline attribute should be irrelevant).
  2. Redirect the standard output like so: Console.SetOut(outputWriter); where outputWriter is a TextWriter that writes to the text view.
  3. Start the application and observe the the weird string value written to the text view.
  4. Resize the window or enter and exit full screen and observe the same value written multiple times.

Expected behavior This string value should not be written to the standard output.

Screenshots Screenshot 2023-02-06 204536

Desktop (please complete the following information):

  • OS: Windows 10

Issue Analytics

  • State:open
  • Created 7 months ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
BDispcommented, Feb 7, 2023

Ok no problem. For your information there are 3 official drivers and another for tests (FakeDriver).

If you are running on a Windows OS:

  • If you running with the Application.UseSystemConsole as false (default) then you are using the WindowsDriver.
  • If you running with the Application.UseSystemConsole as true then you are using the NetDriver.

If you are running on a Linux or macOS:

  • If you running with the Application.UseSystemConsole as false (default) then you are using the CursesDriver.
  • If you running with the Application.UseSystemConsole as true then you are using the NetDriver.

So the NetDriver is a cross platform driver but more slower.

1reaction
BDispcommented, Feb 7, 2023

I already expected that. Was changed from “\u001b[3J” to “\u001b[0J”. This code is in the ResizeScreen method of the WindowsDriver.cs. Removing it solves the issue. That PR is still under development, I think. WindowsDriver can not have escape sequences because it isn’t configured to use virtual terminal, so it’s supposed to output that characters if the console output is redirected, on theses terminals (cmd, vsdebugger, conhost, pwsh). Strangely the escape sequences are executed on the Windows Terminal but, unfortunately still have some incompatibilities with legacy terminal, like not allowing resize the console buffer size but only the window size.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Junk values in C string when printing to stdout and writing ...
I'm playing around with C strings and streams to get a better understanding of them. ... A note on this: In each iteration...
Read more >
Writing raw bytes to stdout? : r/rust
It prints an unprintable character (which is fine), the byte value 255, and if I redirect stdout to a file the size is...
Read more >
Console.WriteLine Method (System)
WriteLine(String ). Writes the specified string value, followed by the current line terminator, to the standard output stream.
Read more >
fprintf() - printf() - sprintf() — Format and Write Data
The sprintf() function formats and stores a series of characters and values in the array pointed to by buffer. Any argument-list is converted...
Read more >
Why the number input is the worst input
When the number input contains an invalid value and you retrieve the value, you get a blank string. Valid numbers include more than...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found