Parse php to get the encoding format of the string of function

  • 2020-06-15 07:58:45
  • OfStack

If you do not know the encoding format of the string, you can check the character as follows:
$encode = mb_detect_encoding ($string array (" ASCII, "' UTF - 8 '," GB2312 ', "GBK", 'BIG5'));
echo $encode;
So we know what it's coded for. Subsequent operations can also transcode it:
if ($encode = = "UTF - 8") {
$string = iconv (" UTF - 8 ", "GBK", $string);
}

Related articles: