0

i try to fix very easy problem, but in fact....it is hell !

In CSV file i got the following string :

"Couleur d’étagère"

The apostroph is in msword format, and i want to replace the char by a true apostroph.

So, in my result, following string is displayed :

enter image description here

I use some tricks listed in these questions :

How to replace Microsoft-encoded quotes in PHP

how to replace apostrophe (’) with single quote(')

If i apply this answer :

function convert_smart_quotes($string) 
{ 
    $search = array(chr(145), 
                    chr(146), 
                    chr(147), 
                    chr(148), 
                    chr(151)); 

    $replace = array("'", 
                     "'", 
                     '"', 
                     '"', 
                     '-'); 

    return str_replace($search, $replace, $string); 
} 

It works, the bad apostroph is well replaced, but i obtain very strange result, and i dont know why :'(

enter image description here

bahamut100
  • 1,795
  • 7
  • 27
  • 38
  • 1
    I found the question you lifted this solution from, and I'm confused why you lifted code from the _question_ and not the _answer_. – Sammitch Jul 22 '20 at 18:18
  • Thank you so much, i dont understand why, but the answer linked to this post seems to fix my problem. – bahamut100 Jul 22 '20 at 22:25

0 Answers0