过滤xml中的不合法字符

public function filterStringXml($str) {
$str = @iconv(‘UTF-8′, ‘GBK’, $str);
$str = @iconv(‘GBK’, ‘UTF-8′, $str);
$str = str_replace(“\xC”, ”, $str);

$str = preg_replace(‘/[^\x{0000}-\x{FFFF}]/iu’, ”, $str);
$str = preg_replace(“/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/”, “”, $str);
return $str;
}