|
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
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 would be greatly appreciated. Thanks! |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
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 would be >> greatly appreciated. Thanks! >> > >PHP has a couple of built-in functions that might 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, "ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèé êëìíîïðñòóôõöøùúûüýÿ", "SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaacee eeiiiionoooooouuuuyy"); } $new_str = ereg_replace( "[^A-Za-z0-9]", "", $str ); |
|
![]() |
| Outils de la discussion | |
|
|