PHP Detect Encoding and Change to UTF-8 07/05/2017 Quick notes Detect and convert encoding to UTF-8 in PHP. 123456789function changeEncoding($text){ $encodeType = mb_detect_encoding($text, array('UTF-8', 'ASCII', 'GBK')); if ($encodeType=='UTF-8') { return $text; //No need to change } else { //return iconv($encodeType, "UTF-8//ignore", $text); return mb_convert_encoding($text, "UTF-8", $encodeType); //Change to UTF-8 }} Prev Deploy Java Web Maven Project on Remote Tomcat Server Next Docker Expose Ports