$str = "掠です。わたしは掠です。";
$regRule = "(.*)&#([0-9]+);(.*)";
while(ereg($regRule, $str, $match))
$str = $match[1]."&#".sprintf("%x", $match[2]).";".$match[3];