Unicode characters to html entities

09 May 2014

function unicode\_escape\_sequences($str){  
 $working = json\_encode($str);  
 $working = preg\_replace('/\u([0-9a-z]{4})/', '&#x$1;', $working);  
 return json\_decode($working);  
}