i think you can add this
$source = preg_replace_callback('/&#x(\d+);/mi', function($m){return utf8_encode(chr('0x'.$m[1]));}, $source); // decimal notation