我正在解析一些东西,并遇到一个奇怪的撇号’
,这会破坏我在├ó┬Ç┬Ö
我尝试了什么:
htmlentities()
,iconv()
,utf8encode()
,utf8_decode()
我的消毒功能,目前有点凌乱,并试图摆脱那个恶人
public function sanitizeName($name) {
$valid = range('a', 'z');
$valid = array_merge($valid, range('A','Z'));
$valid = array_merge($valid, range(0,9));
$valid = array_merge($valid, array('_',',','.','?','!',' ','-',':',';','#','+', '"'));
$name = trim($name);
$name = str_replace(array('\\', '/','’', '`', '´'), '', $name);
$name = preg_replace('/\[.+\]/', '', $name);
$name = preg_replace('/\(.+\)/', '', $name);
$name = utf8_decode($name);
$valid_name = '';
for($i = 0, $len = strlen($name); $i < $len; $i++) {
if(in_array($name[$i], $valid)) {
$valid_name .= $name[$i];
}
}
if(stripos($valid_name, '├') !== false) { //that one isn't even triggering
echo 'adsfg';die; //even though the character is there
}
$name = trim($valid_name);
if(strlen($name) > 0) {
return $name;
}
return null;
}
现在,我怎么能摆脱它?