Well you'd have to use ENT_QUOTES to get it to translate apostophes, and htmlentities translatesr more characters than htmlspecialchars. But to get rid of low level binary characters, e.g to get rid of values lower than 32 and replace them with !
$badChars = array();
for ($i = 0; $i < 32; $i++)
{
$badChars[] = chr($i);
}
$myData = str_replace($badChars, '!', $myData;
Regular expressions are better but I haven't got my mind in that gear today.