My PHP application changes my apostrophe character to �
What is my crime?
My PHP application changes my apostrophe character to �
What is my crime?
Click the Microsoft Office Button , and then click Word Options.
Click Proofing, and then click AutoCorrect Options.
In the AutoCorrect dialog box, do the following:
Click the AutoFormat As You Type tab, and under Replace as you type, select or clear the "Straight quotes" with “smart quotes” check box.
Click the AutoFormat tab, and under Replace, select or clear the "Straight quotes" with “smart quotes” check box.
oh if you must:
<?php
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);
}
?>
alternative replace to keep them for people like David Harkness
<?php
$replace = array('‘',
'’',
'“',
'”',
'—');
?>
You will want to make sure your server is sending the UTF-8 character set on the
Content-Type
header. The curly quotes use more than one byte so you need an appropriate charset to reflect that. If your server is not sending the charset in the header, most browsers will assume you are using the standard ISO-8859 charset that only uses one byte per character which would show in that you are getting 3 characters from only one character that you inputted.If you use Apache, you should set your default character set like so in the httpd.conf:
If you do not have access to your server configuration, you can send a header from php before any content is outputted.