AAAAArgghh!
Why do some Word Processors spew out such a pile of bloated incompatible rubbish?!
If you’ve got any type of CMS and your web pages are showing “junk character” symbols (usually an incongruent question mark of some type,) likelihood is the string you are echoing contains some type of “smart” characters.
There’s a misnomer if ever there was one. Regardless. Onwards.
Try this function:
//replace smart quotes
function convert_smart_quotes($string)
{
$search = array(chr(145),
chr(146),
chr(147),
chr(148),
chr(151),
chr(150),
chr (133),
chr(149)
);
$replace = array("'",
"'",
'"',
'"',
'--',
'-',
'...',
"•"
);
return str_replace($search, $replace, $string);
}
I pinched bits of it from these pages:
http://www.liamdelahunty.com/tips/remove_special_characters.php
Cheers.
Tags: 3 Comments

ironically, of course, WP uses smart quotes and screws up the code, as so eloquently noted by a gentleman in another post here: http://www.alexpoole.name/seo/155/simple-php-article-spinner/comment-page-1#comment-593 You’d do well therefore to fix the quotes before attempting to run the code. I will get around to fixing this one day, honest!
For me it doesn’t work. But this one yes: http://www.toao.net/48-replacing-smart-quotes-and-em-dashes-in-mysql
They do it also in client side with JavaScript in http://www.kevinkorb.com/post/37
The problem is that in many blogs and other websites they do the opposite: you enter data with the keyboard default quotes (vertical) and when you submit they convert them to curly ones ( they can do for example with http://pastebin.com/CEK0NN43 ). If the submited data is a computer code you have normally to put the quotes as straight again so the code works.
In client side they do the opposite like shown in http://stackoverflow.com/questions/2202811/converting-straight-quotes-to-curly-quotes
I’ve copied the codes that worked for me: https://pzt.me/9l95