ANSI Escape Sequences

XxBartmanxX

Newcomer
Joined
Dec 8, 2003
Messages
10
Location
Oregon
I have a telnet server coded in C#, and I am trying to send text that is colorized to the client. This should be pretty trivial, but as it turns out it's not wanting to work.

Here's how it works:

For red foreground color you would send "\033[31m" to the telnet client. "\033" is the hex code for the Esc key I believe.

Now, this worked fine and dandy back in my C++ days but for some reason C# is ignoring the entire escape code. It sees "\0" and interprets it as null, instead of looking at the whole "\033".

Basically, I need to force it to look at the whole code and not just the \0. I am completely stumped at this point.

To recap, I need it to interpret "\033" as a whole, and not as "\0 33".

Thanks,
Bartman
 
I don't know much of C# but maybe the problem is solved replacing the "\033" to "\\033" did you try that?


I also heard that C# has a new feature with strings that if you put before the string an @ it will be taken without escape characters or something like that im not sure about the last thing but you can try like @"\033".


--
Bye,
Ronq.
 
Hey RonQ,

Thank you for your reply. The @ character is for the string literal, which is exactly what you described. However, the problem is that \033 IS an escape code :confused: It represents pushing the Esc key on your keyboard, much like \b represent's pushing backspace.

Putting the extra slash in has the same effect as the @ string literal :-\

Anyone else have any ideas how to make it evaluate '\033' has a whole and not as null followed by 33?

Thanks
 
Back
Top