将所有 \u 符号转换为 UTF8

convert all \u symbols into UTF8

我的测试代码示例:

<?
$city = "L\u00e9ry, Quebec";
echo 'city original: '.$city.'<br>';
$city = preg_replace('/u([\da-fA-F]{4})/', '&#x;', $city);
echo 'city modified: '.$city.'<br>';
?>

我的结果是:

city original: L\u00e9ry, Quebec
city modified: L\éry, Q

我遇到了一些问题...谢谢

这应该适合你:

$city = preg_replace('/\\u([0-9a-fA-F]{4})/', '&#x;', $city);

输出:

city original: L\u00e9ry, Quebec
city modified: Léry, Quebec