function convertNumericEntities($text)
{
if (strlen($text) < 4) {
return $text;
}
// Convert other HTML entities to the current charset characters.
$codec = eZTextCodec::instance('unicode', false);
$pos = 0;
$domString = "";
while ($pos < strlen($text) - 1) {
$startPos = $pos;
while (!($text[$pos] == '&' && isset($text[$pos + 1]) && $text[$pos + 1] == '#') && $pos < strlen($text) - 1) {
$pos++;
}
$domString .= substr($text, $startPos, $pos - $startPos);
if ($pos < strlen($text) - 1) {
$endPos = strpos($text, ';', $pos + 2);
if ($endPos === false) {
$pos += 2;
continue;
}
$code = substr($text, $pos + 2, $endPos - ($pos + 2));
$char = $codec->convertString(array($code));
$pos = $endPos + 1;
$domString .= $char;
} else {
$domString .= substr($text, $pos, 2);
}
}
return $domString;
}