I don’t know about you, but I have a bunch of people using the tools my team and I develop at work who constantly copy-and-paste from MS Word bringing all of its wonderful special characters with it. Then they save and it gets into the database and to the live site…which of course leads to them calling me to ask about the strange symbols in product descriptions. Two problems here: the developer isn’t cleaning his data well enough before sending to the database, and then the staff here can’t figure out how to open notepad but can figure out how to turn their ‘smart’ quotes back on no matter how often we disable it on them.
So in case you suffer this same burden, here is a very simple function you can use to clean up your strings:
function cleanUpString($string) {
return str_replace(
array(
chr(145),
chr(146),
chr(147),
chr(148),
chr(151),
chr(133),
chr(130)
),
array(
"'",
"'",
'"',
'"',
'-',
'...',
','
),
$string
);
}