You are here: Re: Remove all unicode from a string « PHP Language « IT news, forums, messages
Re: Remove all unicode from a string

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("&#8211;" => "-",
"&#8212;" => "-",
"–" => "-",
"&#8216;" => "'",
"’" => "'",
"&#8217;" => "'",
"‘" => "'",
"&#8230;" => "...",
"…" => "...",
"“" => "\"",
"&#8220;" => "\"",
"”" => "\"",
"&#8221;" => "\"");
$str = strtr($str, $unicode_array);
return strtr($str, "ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ",
"SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");
}



$new_str = ereg_replace( "[^A-Za-z0-9]", "", $str );

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация