Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

Member 10284633

@Member 10284633
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to remove escape sequece from string while telnet to HP procurve devices
    M Member 10284633

    I run into the same problem and have figured out a workaround that works for as. It is not a perfect solution. I use a regular expressions substituions between the TCP buffer and the Telnet protocol because the firmware sometimes use unknow esc sequnences that bother the telnet/terminal protocol. I use Perl for switch automation but i try to translate it to C# (The orginal is a Perl module

    Regexp::Common::ANSIescape

    ). I use this expression

    \x1BE/\n

    before the big one and this after

    \[[0-9]+;[0-9]+H

    because the firmware use sometimes esc secuences that does not exist.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Threading.Tasks;

    namespace ProcurevAnsiFilter {
    class Program {
    const string CHAR_STR = @"(.|\n)*?";

    const string CSI\_7BIT    = @"\\x1B\\\\\\x5B";
    const string CSI\_8BIT    = @"\\x9B";
    
    const string CSI\_7OR8    = @"(?:" + CSI\_7BIT + "|" + CSI\_8BIT + ")";
    
    const string C1\_NST\_8BIT = @"\[\\x80-\\x8F\\x91-\\x97\\x99\\x9A\\x9C\]";
    const string C1\_NST\_7BIT = @"\\x1B\[\\x40-\\x4F\\x51-\\x57\\x59\\x5A\\\\\\x5C\]";
    
    const string C1\_STR\_7BIT = @"\\x1B\[\\x5D\\x50\\x58\\x5E\\x5F\]";
    const string C1\_STR\_8BIT = @"\[\\x9D\\x90\\x98\\x9E\\x9F\]";
    
    const string C1\_STR\_7OR8 = @"(?:" + C1\_STR\_7BIT + "|" + C1\_STR\_8BIT + ")";
    
    const string ST\_7BIT     = @"\\x1B\\\\\\\\";
    const string ST\_8BIT     = @"\\x9C";
    const string ST\_7OR8     = @"(?:" + ST\_7BIT     + "|" + ST\_8BIT     + ")";
    
    
    static void Main(string\[\] args) {
    string\[\] tmp = new string\[\] {
      @"(?:\[\\x30-\\x3F\]\*)(?:\[\\x20-\\x2F\]\*\[\\x40-\\x7E\])",
      C1\_NST\_7BIT,
      C1\_NST\_8BIT,
      C1\_STR\_7OR8 + CHAR\_STR + ST\_7OR8
    };
      string regex = "(?:" + string.Join("|", tmp) + ")";
    
      Regex reg = new Regex(regex);
    }
    

    }
    }

    C# com help tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups