I am always confused on how to deal with html characters. Not sure whether to decode or encode, and sometimes neither of them solve the problem.
How do I deal with characters like:
"Continuing the pregnancy trend…is Gwen Stefani….“They and the whole family are delighted,†Douglas Rossdale, Gavin’s "
Any help or advice would be appreciated.
Hello brant,
This is most likely to do with the character set of the data Vs the character set of the HTML page you are generating. This can normally be fixed by sending the appropriate character set header at the top of your script, using PHP's header() function.
If you're not sure what character set your data is in, I would suggest first trying utf-8, with the following code on the very first line of your script - it must go BEFORE any output has been generated, otherwise PHP cannot send the header:
<?php
header("Content-Type: text/html; charset=utf-8");
?>
If the characters are still not displayed correctly, try iso-8859-1, as follows:
<?php
header("Content-Type: text/html; charset=iso-8859-1");
?>
Hope this helps!
Cheers,
David.