How to correct double-encoded UTF-8 strings sitting in MySQL utf8_general_ci fields?

后端 未结 6 1548
感动是毒
感动是毒 2020-12-15 07:42

I have to redesign a class where (amongst other things) UTF-8 strings are double-encoded wrongly:

$string = iconv(\'ISO-8859-1\', \'UTF-8\', $string);
:
$str         


        
6条回答
  •  萌比男神i
    2020-12-15 08:31

    MySQL provides a regexp match but no regexp replace, so you're usually better off iterating through each row in php, converting as needed, and updating the row if it has been changed.

提交回复
热议问题