Is a translation of the below code at all possible using PHP?
The code below is written in JavaScript. It returns html with numeric character references where needed. Ex
Use mb_encode_numericentity:
$convmap = array(0x80, 0xffff, 0, 0xffff); echo mb_encode_numericentity($utf8Str, $convmap, 'UTF-8');