Character normalization


I’d like to normalize in a string the characters below. To no effect so far.

    //character normalization
    $text = str_replace("’","'",$text);
    $text = str_replace("“",'"',$text);
    $text = str_replace("”",'"',$text);
    $text = str_replace("’","'",$text);

Once echoed, $text doesn’t reflect a single change compared to original string.

How would you do that? Am I missing an obvious point?


If you are stripping Ms Word style quotes take a look at this user contributed note PHP: str_replace - Manual

Your $text code might be accepting utf-8 strings or char encoded strings, its not clear from what you have posted.

Thanks for your reply.

Therein lies the problem, I guess. I’m still very confused when it comes to char encoding. Should my $text be utf-8 or not (mb_detect_encoding() says it is)? Is the function you posted to dealing with utf-8 strings or not?

For the sake of resolving the problem faster, I shall add that $est is the result of a $_POST variable.