C#:转换目标为Unix外壳的字符串用于Windows命令提示符 [英] c#: transform a string targeted for the unix shell use for the windows command prompt

查看:158
本文介绍了C#:转换目标为Unix外壳的字符串用于Windows命令提示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我从套接字流中取出的示例字符串。

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  

如果要查看我希望打开unix / linux shell的输出,键入 echo -e ,后跟一个空格,然后是单引号引起的上述字符串,然后按Enter键。输出如下所示:

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:

                     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.

推荐答案

几个小时前,我问了一个几乎相同的问题:开源C#VT100服务器。您想要一个能够理解vt100转义命令的客户端库。

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.

我搜索了一段时间,到目前为止,还没有找到任何非常好的vt100 C#库。我已经开始定制一个了,既然我真的只需要解释左右箭头和退格键,就用了很长时间。

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.

幸运的是,vt100标准是非常混杂,并且不太复杂。我认为您不需要花费很多时间编写一些代码来理解示例中的转义命令。该链接具有 VT100转义序列的简洁列表。 (您需要向下滚动一点)。另一个不错的网站是 vt100.net

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

转换为下面的ASCII,用于设置光标位置。

which translates to the ASCII below and is used to set the cursor position.

ESC [ H

第二个是

\033[J



which translates to the ASCII sequence below and means clear the line to the end of screen.

ESC [ J 

这篇关于C#:转换目标为Unix外壳的字符串用于Windows命令提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆