|
Posted by Gleep on 06/14/07 06:02
On Thu, 14 Jun 2007 07:15:02 +0200, iktorn <spam@phpfreelancer.net> wrote:
>jerry@mynetserv.com napisa?(a):
>> I am trying to use php to remove all unicode from a string. What I am
>> seeing it the white question mark with a black diamond. I have tried
>> html_entity_decode and preg_replace but had no luck. Any help would be
>> greatly appreciated. Thanks!
>>
>
>PHP has a couple of built-in functions that might help you:
>
>utf8_decode (decoding to iso-8859-1)
>iconv (decode to almost any charset you need, use //IGNORE to decode all
>string)
these come in handly
function asciify($str)
{
$unicode_array = array("–" => "-",
"—" => "-",
"" => "-",
"‘" => "'",
"" => "'",
"’" => "'",
"" => "'",
"…" => "...",
"
" => "...",
"" => "\"",
"“" => "\"",
"" => "\"",
"”" => "\"");
$str = strtr($str, $unicode_array);
return strtr($str, "¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ",
"SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");
}
$new_str = ereg_replace( "[^A-Za-z0-9]", "", $str );
[Back to original message]
|