I’m using the PHP DOM for XML and am receiving this error: xmlEscapeEntities : char out of range. My database is UTF-8, and as far as I can tell, so is everything else. I’m wondering how this bad data got in there and what I can do about it. Firstly, how to avoid this error? Can I escape that data before output?
Never mind. I got it.
$dom = new DOMDocument(‘1.0’,‘utf-8’);
Cool, I had the same problem and this fixed it.
do you have any idea what was causing the problem?
It’s been a while, but if I remember correctly, adding the utf-8 encoding is what fixed it.
instead of this DOMDocument(‘1.0’);
Just a guess, but maybe DOMDocument assumes iso-8859-1 as input, if you don’t specify otherwise. It would then read the utf-8 encoded data wrong and possibly end up with illegal code-points.