我使用cURL,在获取查询后我会回复下一个HTML代码:
$rezult = '<h5>\u0420\u0443\u0431\u0440\u0438\u043a\u0430:<\/h5>\n\t<select id="\"category_2\"" name="\"category\"" size="0" lev="\"2\"" onchange="\"getCategory(this);\"">\n\t <option value="\"213\"" t="\"child\"" title="\"\u041c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0435" \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u044b\"="">\u041c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u044b<\/option> </option><option value="\"214\"" t="\"child\"" title="\"\u0410\u043a\u0441\u0435\u0441\u0441\u0443\u0430\u0440\u044b\"">\u0410\u043a\u0441\u0435\u0441\u0441\u0443\u0430\u0440\u044b<\/option>></select></h5>'
如何在UTF 8中转换它? PS:我试试
mb_convert_encoding($rezult, "UTF-8);
iconv('ASCII', 'UTF-8//IGNORE', $rezult);
但不是rezult。
我已经找到了solutoin:
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
echo stripslashes(
html_entity_decode(
preg_replace_callback('/\\\\u([\\da-f]{4})/i', 'replace_unicode_escape_sequence', $rezult)
)
);
感谢所有人。
答案 0 :(得分:-1)
$rezult = utf8_encode($rezult);