Simple, but I found it useful when
htmlspecialchars() and
htmlentities() weren't doing the trick in an entirely utf-8, multi-lingual XML file:
PHP Code:
function xmlspecialchars($str) {
return str_replace(''',''',htmlspecialchars($str,ENT_QUOTES,'UTF-8'));
}
Probably flawed, but worked for me when I needed it.