这是一个 UTF-8 编码的源文件。我一定遗漏了一些明显的东西,但我已经尝试了我能想到的所有排列。
<?php
$bad = array( chr(130), chr(145), chr(146), chr(147), chr(148), chr(150), chr(151), chr(173), chr(160) );
$good = array( chr( 44), chr( 39), chr( 39), chr( 34), chr( 34), chr( 45), chr( 45), chr( 45), chr( 32) );
print_r($bad);
print_r($good);
$str = <<<EOF
bad comma ‚
bad quote ‘
bad quote ’
bad quote “
bad quote ”
bad dash –
bad dash —
bad dash
bad space
EOF;
echo $str;
$clean = str_replace($bad, $good, $str);
echo "\n";
echo( $clean);
当我在浏览器中打开它并查看源代码时......
Array
(
[0] => ‚
[1] => ‘
[2] => ’
[3] => “
[4] => ”
[5] => –
[6] => —
[7] =>
[8] =>
)
Array
(
[0] => ,
[1] => '
[2] => '
[3] => "
[4] => "
[5] => -
[6] => -
[7] => -
[8] =>
)
bad comma ‚
bad quote ‘
bad quote ’
bad quote “
bad quote â€
bad dash –
bad dash —
bad dash Â
bad space
bad comma ‚
bad quote ‘
bad quote ’
bad quote “
bad quote â€
bad dash â€"
bad dash â€"
bad dash Â-
bad space