I'm creating a logic to replace the unprintable characters from a string with a space, just that I'm confused if it is the same ASCII characters and Unicode characters, I have reviewed about how to do using regex.replace function but I don't understand how to validate if the character from the string is between the below conditions.
This is the requirement I got, replace with a space:
- All ASCII characters with values of 0 through 31.
- Unicode characters with values 127, 129, 141, 143, 144 and 157
I have tried this (I believe this works for ASCII characters) but do I handle unicode characters?
newPartNum = Regex.Replace(PartNum, @"[^\u0020-\u007E]", " ");
Any help would be appreciate it.