PHP DOM automatically decodes. Eg * is decoded when creating a DOMElement. Is there a way to prevent this. One solution is to preprocess the text and afterwords postprocess it but this seems more like a hack.
example code:
$domDoc = new \DOMDocument();
$domEl = $domDoc->createElement('foo', 'text with * in it');
$domDoc->appendChild($domEl);
echo $domDoc->saveXML();
DOMDocument, or rather libxml, has a boolean flag substituteEntities:
However, this won’t work for your ASCII entities because they are predefined. There was a bug report asking for this for PHP 5.1.4, which is marked as “Not A Bug”, because
Also see http://xmlsoft.org/entities.html