Wednesday, 28 August 2013

Replace all non-printable UTF-8 characters with spaces

Replace all non-printable UTF-8 characters with spaces

I need to sanitaze some user input and I need to remove all the characters
can cause problems such as Null Byte or useless ones(such as \n or \t),
because the inputs are or strings or html code. At this moment I'm using
this to remove the tab, break-line, etc:
preg_replace('/\s+/','',$_POST['id'])
but isn't sufficent, I have found this:
preg_replace( '/[^[:print:]]/',' ',$_POST['val'])
But I don't understand if it strips also characters that shouldn't be
deleted, such as german or arabic chars or punctation or symbols

No comments:

Post a Comment