Why does Console.Write insert escape sequence to my output?

ccchen

Member
Joined
Sep 1, 2021
Messages
5
Programming Experience
1-3
I write a very small app to read from serial port then use Console.Write to output. I notice Console.Write treats its output as VT100 and insert Escape sequences like <ESC>[6n to the string

This <ESC>[6n won't cause any issue if the console is indeed a VT100 like terminal, but when I write my own terminal, I need to deal with them.

Is there a way to suppress the insertion of such ESC sequences from Console.Write?
 
Is there a way to suppress the insertion of such ESC sequences from Console.Write?
Yes. Filter the string before passing it to Console.Write().
 
Wait. Are you using .NET Core on Linux or Mac?

.NET Framework and .NET Core on Windows does not use ESC codes for formatting.
 
It's the mono implementation that is very likely inserting the ESC codes.
 
.NET framework, then test it with mono on debian
That really is information that you should be providing upfront. We can't always provide everything that might be relevant but that is something that is out of the ordinary so definitely worth mentioning.
 
That really is information that you should be providing upfront. We can't always provide everything that might be relevant but that is something that is out of the ordinary so definitely worth mentioning.
My bad, I thought C# was from the same development team.....
 
Back
Top Bottom