Set encoding to UTF-8 if not UTF-8


<?php
// Fixes the encoding to uf8
function fixEncoding($in_str)
{
 
$cur_encoding = mb_detect_encoding($in_str) ;
  if(
$cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8"))
    return
$in_str;
  else
    return
utf8_encode($in_str);
}
// fixEncoding
?>

Soruce: http://www.php.net/manual/en/function.utf8-encode.php#89789

Knowledge keywords: