Consider the requirement to strip invalid characters from a string. The characters just need to be removed and replace with blank or string.Empty.
Something to consider -- if this is for passwords (say), you want to scan for and keep good characters, and assume everything else is bad. Its easier to correctly filter or good things, then try to guess all bad things.
For Each Character If Character is Good -> Keep it (copy to out buffer, whatever.)
jeff