MS Word "Curly Quotes"
I'm sure You've seen it before, where your database driven website ends up riddled with that weird image that looks like a diamond with a question mark in it. It took me a while to figure out what the problem was. It turns out, users of my site were typing information in MS Word and pasting it into the form.
These are special MS Word "we think this is prettier so your stuck with it" characters. If you are using PHP to parse your forms, you should run all input form items through the following function.
<?PHP
function cleanup($input){
$messychar = array(chr(133) => '...',
chr(145) => "'",
chr(146) => "'",
chr(147) => '"',
chr(148) => '"',
chr(149) => '*',
chr(150) => '-',
chr(151) => '-',
chr(152) => '~'
);
$cleaned = str_replace(array_keys($messychar),
$messychar, $input);
return $cleaned;
}
?>
Special Notes:
You can add other characters to this if you want. Just know that, in order to type an ellipse for instance (that's the first item in the array), you would have to type Alt+0133 on your keyboard. So, to get the PHP chr() for it, just take off the Alt+0.
Another tip, if you want to clean up curse words, you can do the same thing " shit " => " $@!! " (mind the spaces in the strings so that you don't end up changing shitzue to $@!!zue.
