c#: transform a string targeted for the unix shell use for the windows command prompt
Here is a sample string I got off a socket stream.
\033[H\033[J\033[1;30HSUPERVISOR MAIN MENU\033[6;5H 0. Exit Exit\033[7;5H 1. Help Display help\033[8;5H 2. Control Calling lists and users\033[9;5H 3. Campaign Campaigns\033[10;5H 4. Manage
If you want to see the output I expect open a unix/linux shell, type echo -e followed by a space followed by the above string in single quotes and hit Enter key. The output appears something like:
开发者_JAVA百科 SUPERVISOR MAIN MENU
0. Exit Exit
1. Help Display help
2. Control Calling lists and users
3. Campaign Campaigns
4. Manage
I want the same output except it should be in memory...I require to work with it later...any ideas.
I asked an almost equivalent question a few hours ago: Open Source C# VT100 Server. You want a client library that understands the vt100 escape commands.
I searched around for a while and to date haven't found any very good vt100 C# libraries. I've gotten started on a custom one and since I really only need to interpret left and right arrows and backspace it hasn't taken long.
Luckily the vt100 standard is very promiscuous and not overly complex. I don't think it would take you very long to whip up some code to understand the escape commands in your example. This link has a nice concise list of the VT100 escape sequences (you need to scroll down a bit). Another good site is vt100.net.
In your example the escape sequences are being in octal. Your first escape sequence is:
\033[H
which translates to the ASCII below and is used to set the cursor position.
ESC [ H
The second one is
\033[J
which translates to the ASCII sequence below and means clear the line to the end of screen.
ESC [ J
精彩评论