| 
	
 | 
 Posted by Gleep on 03/21/07 01:14 
On 20 Mar 2007 11:01:28 -0700, matthud@gmail.com wrote: 
 
>The following string: 
>"US generals will quit if Bush orders Iran attack" 
> 
>is being stored in my table as: 
> 
>"US generals âwill quitâ if Bush orders Iran attack" 
> 
>The only PHP function I'm applying to the string is 
>mysql_real_escape_string, and that doesn't appear to be the root of 
>the problem. I'm using utf8_general_ci as my collation. 
> 
>Forgive my ignorance. 
 
 
 
user this function on all incoming variables 
will clean out the junk characters and replace with ascii 
 
<?php 
    function asciify($str) 
    { 
        $unicode_array = array("–" => "-", 
                               "—" => "-", 
                               ""       => "-", 
                               "‘" => "'", 
                               ""       => "'", 
                               "’" => "'", 
                               ""       => "'", 
                               "…" => "...", 
                               "
"       => "...", 
                               ""       => "\"", 
                               "“" => "\"", 
                               ""       => "\"", 
                               "”" => "\""); 
        $str = strtr($str, $unicode_array); 
        return strtr($str, "¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ", 
                           "SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy"); 
    } 
?> 
 
 
darn  look like my new reader will not post the correct  charas 
so I will also attach the file
 
  
Navigation:
[Reply to this message] 
 |