Later in the manual found the Is_utf8 function, so that, combined with the ICONV function, my problem is solved. This function is shown below:
Copy the Code code as follows:
function Is_utf8 ($string) {
Return Preg_match ('%^ (?:
[\x09\x0a\x0d\x20-\x7e] # ASCII
| [\XC2-\XDF] [\X80-\XBF] # Non-overlong 2-byte
| \XE0[\XA0-\XBF][\X80-\XBF] # excluding overlongs
| [\xe1-\xec\xee\xef] [\X80-\XBF] {2} # straight 3-byte
| \XED[\X80-\X9F][\X80-\XBF] # excluding surrogates
| \XF0[\X90-\XBF][\X80-\XBF]{2} # Planes 1-3
| [\xf1-\xf3] [\X80-\XBF] {3} # planes 4-15
| \XF4[\X80-\X8F][\X80-\XBF]{2} # Plane 16
) *$%xs ', $string);
}//Function Is_utf8
If you want to delve into it, it's recommended to look at the section "multibyte String Functions" on the PHP manual.
The above describes the converse one star php mb_convert_encoding get the string encoding type implementation code, including the content of Converse a star, want to be interested in PHP tutorial friends helpful.