📜  php 过滤非 utf-8 字符 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:04.580000             🧑  作者: Mango

代码示例1
function remove_bs($Str) {  
  $StrArr = str_split($Str); $NewStr = '';
  foreach ($StrArr as $Char) {    
    $CharNo = ord($Char);
    if ($CharNo == 163) { $NewStr .= $Char; continue; } // keep £ 
    if ($CharNo > 31 && $CharNo < 127) {
      $NewStr .= $Char;    
    }
  }  
  return $NewStr;
}