Command disabled: backlink

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(".");
 
?>

Linkbacks

Use the following URL for manually sending trackbacks: https://rigo.info/lib/plugins/linkback/exe/trackback.php/en:blog:un-accenting_text
en/blog/un-accenting_text.txt · Utolsó módosítás: 2009-04-14 00:00 (külső szerkesztés)
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0