如何在php中过滤字体字符

I have an arial character giving me a headache. U+02DD turns into a question mark after I turn its document into a phpquery object. What is an efficient method for removing the character in php by referring to it as 'U+02DD'?

Use preg_replace and do it like this:

$str = "your text with that character";

echo preg_replace("#\x{02DD}#u", "", $str); //EDIT: inserted the u tag for unicode

To refer to large unicode ranges, you can use preg_replace and specify the unicode character with \x{abcd} pattern. The second parameter is an empty string that. This will make preg_replace to replace your character with nothing, effectively removing it.


[EDIT] Another way:

Did you try doing htmlentities on it. As it's html-entity is ˝, doing that OR replacing the character by ˝ may solve your issue too. Like this:

echo preg_replace("#\x{02DD}#u", "˝", $str);

You can use iconv() to convert character sets and strip invalid characters.

<?PHP
 /* This will convert ISO-8859-1 input to UTF-8 output and 
  * strip invalid characters
  */
 $output = iconv("ISO-8859-1", "UTF-8//IGNORE", $input);

 /* This will attempt to convert invalid characters to something
  * that looks approximately correct.
  */
 $output = iconv("ISO-8859-1", "UTF-8//TRANSLIT", $input);
?>

See the iconv() documentation at http://php.net/manual/en/function.iconv.php