I have a string that has extended ASCII char ÿ in it and I am trying to delete it. How do I find it in a string and delete it from a string like this: 1ÿ1ÿ0ÿÿÿ?
The byte array, buffer = { 49, 0, 255, 255, 49, 0, 255, 255, 48, 0, 255, 255, 255, 255 }
I am using C# and the string was formed from a byte array like so: temp.Add(System.Text.Encoding.ASCII.GetString(buffer));
Then, the first item in temp is "1\0??1\0??0\0????"
I would like to remove the non-ASCII values from the string, or better yet the buffer.
To remove the characters from the buffer before creating the string:
If you try to convert it to a string and then remove the offending characters, you can’t tell the difference between a legitimate
?character and one that was placed there because conversion failed. That is, if your buffer contained:Then the resulting string would start with
??1\0??. The first two question marks are legitimate, but the last two are the result of conversion failure.