Function that convert national characters into ASCII
| From: | Wiktor | Date: | Wed, 19 Oct 2005 16:10:09 +0000 |
| Subject: | Function that convert national characters into ASCII | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-224334@lists.php.net to get a copy of this message | ||
Hi,
Is there a function that will convert any european special characters
into standard ASCII letters eg. polish "ogonki" into a,e,o or german umlauts into
ue,oe...?
something better than this...
//only PL chars
function Utf2Ascii($string)
{
$utf2ascii = array(
"\xC4\x84"=>"A",
"\xC4\x85"=>"a",
"\xC4\x86"=>"C",
"\xC4\x87"=>"c",
"\xC4\x98"=>"E",
"\xC4\x99"=>"e",
"\xC5\x81"=>"L",
"\xC5\x82"=>"l",
"\xC5\x83"=>"N",
"\xC5\x84"=>"n",
"\xC3\x93"=>"O",
"\xC3\xB3"=>"o",
"\xC5\x9A"=>"S",
"\xC5\x9B"=>"s",
"\xC5\xB9"=>"Z",
"\xC5\xBA"=>"z",
"\xC5\xBB"=>"Z",
"\xC5\xBC"=>"z",
);
return strtr($string, $utf2ascii);
}
--
Excuse my english ;)
Pozdrowienia,
Wiktor