To convert to UTF-8, do:
preg_replace('/\\\\u([0-9a-f]{4})/ie', 'mb_convert_encoding("&#x$1;", "UTF-8", "HTML-ENTITIES")', $string);
Since this is an escape function used in JSON, another option would be json_decode . This, however, also requires avoiding double quotes and backslashes before (except for those executed by \uXXXX escape sequences), and adding double quotes around the string. If, however, the string is indeed JSON encoded and that originally motivated the question, the correct answer would naturally be to use json_decode instead of the method described above.
Artefacto
source share