fixEncoding in PHP

By: mrezair  

I found this little function very useful in fixing strings that are not in utf-8 but need be converted .

// 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; 
    return utf8_encode($in_str); 
} // fixEncoding 

Archived Comments

1. Hello
View Tutorial          By: William at 2011-08-01 14:05:10

Most Viewed Articles (in PHP )

Latest Articles (in PHP)

Comment on this tutorial