I have a method that I've written in C# that connects to OpenVMS, runs a command and then returns the output.
One of the DCL procedures it runs returns a "form" in the form of a string which has all sorts of ANSI encoding in it.
What I wish to do is to split the returned string into an array based on the ANSI escape character as a delimiter so that I can further sort it and build a display later on.
The problem i'm having is the escape character doesn't look like its being recognized. When I inspect the string in visual studio I can see the standard ANSI formatting with an arrow pointing left that looks like this: ← between each entry. This is the escape character.
If I paste the same string into notepad++ it shows up as ESC.
I've tried doing a split on the string with \033 being the delimiter, but that didn't work, I've also tried pasting the ESC character into a variable but it simply pastes an empty space.
So I'm wondering how do I find out what character code this escape character is using so that I can use it in my split.
Id post a screenshot but I don't have the rep to do that apparently.
edit: this is whats being returned:
[02;27HDIVIDEND SETUP 11:25 Mon, 21 Jul 2014[04;05HCurrent attach point : VOD_TIM[07;05H Code Description[07;60HDate Run
Its not showing up as a character on StackOverflow but if you imagine the character is infront of each of the segments starting with a [
Edit 2: OKay se we've established that the int char code is 27 so the issue now is how do I use that in my split?
You can try out the splitting your string via Regex
, something like this:
string input = YOUR_STRING_HERE;
string pattern = @"\033";
string[] substrings = Regex.Split(input, pattern);
foreach (string match in substrings)
{
Console.WriteLine("'{0}'", match);
}
Update:
You can use the \e
symbol for the ESC
character in Regex
in .Net, see the full list of escape characters in Regex
here.