I know this a common question but everything I found seems to remove white space.
I'm looking for a regular expression that will strip unprintable characters WITHOUT changing any whitespace. This a function that all user input will be filtered through, which means all the characters you could normally type on a keyboard are valid. Ex: the accents you see in Spanish are valid. Basically anything you could display using the UTF 8 charset.
Because this is SQL Server, I don't think the "SET NAMES UTF8" approach will work.
Here's what I have.
function stripNonPrintable($input)
{
return preg_replace('/[\x00\x08\x0B\x0C\x0E-\x1F]/', '', $input);
}