'Character replacement for Control Sequence Introducer Character in VB? Chr(155)

I have tried all day to replace this character I have in a string which has characters in it... and after googling, I found is called a "Control Sequence Introducer".

It looks like the hex code is 9B and the ASCII code is 155. (I think, from what I've read).

The string comes from a file which I read in, I have some null characters to replace, which is working fine, but just after that I've been working to remove this wierd character.

In notepad++ when I do show all symbols, it looks like this: Conrol Sequence Introducer Character

I tried the following:

strLine = strLine.Replace(Chr(155), " ")

strLine = Replace(strLine , "9B", " ")

strLine = Replace(strLine , "&#x9B", " ")

strLine = Replace(strLine , Chr(155), " ")

strLine= Regex.Replace(strLine, "\c@", " ")

strLine= Regex.Replace(strLine, "\c_", " ")

strLine= Regex.Replace(strLine, "\c", " ")

strLine= Regex.Replace(strLine, "\cA", " ")

strLine= Regex.Replace(strLine, "\cZ", " ")

I found a good section in wikipedia

Control Sequence Introducer Character ANSI Control Sequences

With everything going on in that, perhaps I have the wrong hex code? Does anybody know how to replace this character? I have googled this for awhile now and it's elusive to me how to solve this.



Solution 1:[1]

I did find it finally, using regex and the hex code!

strLine = Regex.Replace(strLine, "\x9B", " ")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shadow2020