I'm trying to replace '\xA0' character in a string to be blank or worst case a space. This code does compile and run, but it won't replace nbsp character with a space.
string line = Stream.ReadLine();
line = line.Replace('\xA0', ' ');
I'm trying to replace '\xA0' character in a string to be blank or worst case a space. This code does compile and run, but it won't replace nbsp character with a space.
string line = Stream.ReadLine();
line = line.Replace('\xA0', ' ');
I found a reasonable solution to this question. So I convert the   � character into a int (65533) so I use that value and use the ToChar() method to get my character and then replace using that character.
string line = Stream.ReadLine();
char SpecNBSPChar = Convert.ToChar(65533);
line = line.Replace(SpecNBSPChar , ' ');
Based on this thread can you try?
line.Replace('\u00A0', ' ');
OK, i am trying to redeem myself here. What about using a Regex? Like this:
string text = " Ph0b0x � ";
string result = Regex.Replace(text, @"[^\x00-\x7F]+", "");
Console.WriteLine(text);
Console.WriteLine(result);
Console.ReadLine();
My results:
Ph0b0x �
Ph0b0x
Regex pattern found here