Remember the data from other Web sites that were crawled to XML in the past at work. However, there is a problem: The Web page will have ASCII control characters. At first I thought it was someone else who joined in order to prevent the collection, and then found one on the filter table plus one. Until they are found, they are all characters in the ASCII table. Find out the reason, it is good to solve.
/**
* Filter control characters according to 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);
}
http://www.bkjia.com/PHPjc/814671.html www.bkjia.com true http://www.bkjia.com/PHPjc/814671.html techarticle remember the data from other Web sites that were crawled to XML in the past at work. However, there is a problem: The Web page will have ASCII control characters. At first I thought it was someone else to avoid ...