更新时间:2023-11-27 10:47:22
mb_convert_encoding()
不是您要实现的正确功能:您应该真正使用 html_entity_decode()代替,因为它只会转换实际的html实体改为UTF-8,并且不会影响字符串中现有的UTF-8字符.
mb_convert_encoding()
isn't the correct function for what you're trying to achieve: you should really be using html_entity_decode() instead, because it will only convert the actual html entities to UTF-8, and won't affect the existing UTF-8 characters in the string.
$text = "äöü ä ö ü ß";
var_dump(html_entity_decode($text, ENT_COMPAT | ENT_HTML401, 'UTF-8'));
给出
string(18) "äöü ä ö ü ß"