Remember that you used to work on other Web sites that you crawled into XML. But there is a problem: the page will have ASCII control characters. At first it was thought that someone else had joined in order to prevent the collection and then found one to add one to the filter table. Until slowly discovered, they were all characters in the ASCII list. Find out why, it's a good solution.
/**
* Filter control characters based on ASCII code
* @param type $string
*/
public static function Special_filter ($string)
{
if (! $string) return ";
$new _string = ';
For ($i =0 isset ($string [$i]); $i + +)
{
$asc _code = Ord ($string [$i]); Get its ASC code
The following code is designed to filter illegal characters
if ($asc _code = = 9 $asc _code = = $asc _code = = 13) {
$new _string. = ';
}
else if ($asc _code > && $asc _code!= 127) {
$new _string. = $string [$i];
}
}
Return trim ($new _string);
}