Un-accenting text

This PHP code snippet is userful in removing accents from international (latin), especially hungarian texts.

<?PHP
 
function unaccent($txt) {
 
  return strtr(recode("utf8..l1",strtr($txt,"őŐűŰ","oOuU")),
  "\xe1\xc1\xe0\xc0\xe2\xc2\xe4\xc4\xe3\xc3\xe5\xc5".
  "\xaa\xe7\xc7\xe9\xc9\xe8\xc8\xea\xca\xeb\xcb\xed".
  "\xcd\xec\xcc\xee\xce\xef\xcf\xf1\xd1\xf3\xd3\xf2".
  "\xd2\xf4\xd4\xf6\xd6\xf5\xd5\x8\xd8\xba\xf0\xfa\xda".
  "\xf9\xd9\xfb\xdb\xfc\xdc\xfd\xdd\xff\xe6\xc6\xdf\xf8"."őŐűŰ",
  "aAaAaAaAaAaAacCeEeEeEeEiIiIiIiInNo".
  "OoOoOoOoOoOoouUuUuUuUyYyaAso"."oOuU");
 
}
 
function doit($dir) {
  foreach(glob($dir."/*") as $entry) {
    echo $entry." => ".unaccent($entry)."\n";
    rename($entry,unaccent($entry));
    if(is_dir($entry)) doit($entry);
  }
}
 
doit(".");
 
?>