a simply function that detect character code and covert to UTF-8
function convertUTF8($data) {
if(!empty($data)) {
$encodeType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5'));
if( $encodeType != 'UTF-8'){
$data = mb_convert_encoding($data ,'utf-8' , $encodeType);
}
}
return $data;
}