如何在C#中telnet到HP Switch时从字符串中删除转义序列 [英] how to remove escape sequence from string while telnet to a HP Switch in C#
问题描述
我正在尝试远程登录HProCurve J9279A交换机,但是当我在文本文件中编写响应时,我在登录提示中收到了一些未知字符。请让我知道如何处理这个并从字符串中删除这些垃圾字符。我可以说这些是一些逃避顺序,不能被字符串识别。
请立即在www.ProCurve.com注册您的产品
?[1; 24r?[1; 1H?[24; 1HUsername:?[?25h?[24; 1H?[?25h?[24; 11H?[24; 11H?] [ ?25h?[24; 11H
请帮助删除上述字符串和命令输出中的未知字符。任何帮助将不胜感激
I am trying to telnet a HProCurve J9279A Switch but i am getting some unknown characters in the login prompt when i am writing the response in text file . Please let me know how to handle this and remove these junk characters from string . I can say these are some escape sequense which in not recognized by string .
Please register your products now at: www.ProCurve.com
[1;24r[1;1H[24;1HUsername: [?25h[24;1H[?25h[24;11H[24;11H[?25h[24;11H
Please help to remove thse unknown characters in above strings and command outputs. any help will be appreciated
推荐答案
看起来像 VT100 转义代码(但我可能是错的,因为我需要一段时间知道这样的事情:))。
获取VT100 ANSI解析器库并将字符串提供给它,我尝试使用libvt100 C#库 [ ^ ],它是一个易于使用的解析界面。
或者如果你手上有太多时间,根据 VT100和VT52转义码图表手动滚动您自己的实现[ ^ ]。
希望这会有所帮助,
Fredrik
That looks like VT100 escape codes (but I could be wrong, it's been a while since I needed to know things like this :)).
Get a VT100 ANSI parser library and feed the string to that, I'd try using the libvt100 C# library[^], it as an easy to use parse interface.
Or if you've got way too much time on your hands, hand-roll your own implementation according to a VT100 and VT52 escape codes chart[^].
Hope this helps,
Fredrik
这篇关于如何在C#中telnet到HP Switch时从字符串中删除转义序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!