Skip to content

Instantly share code, notes, and snippets.

@bladeofsteel
Created May 10, 2014 11:50
Show Gist options
  • Save bladeofsteel/5a07dc19db119973141b to your computer and use it in GitHub Desktop.
Save bladeofsteel/5a07dc19db119973141b to your computer and use it in GitHub Desktop.
Unicode characters to html entities
<?php
function unicode_escape_sequences($str) {
$working = json_encode($str);
$working = preg_replace('/\\\u([0-9a-z]{4})/', '&#x$1;', $working);
return json_decode($working);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment