I have a database that stores some unusual characters input by visitors: e.g. é, á, , í , and ú.
My html 5 web page displays ? instead of the character when I use
<meta charset="utf-8">
but when I use
<meta charset="ISO-8859-1">
the characters are displayed correctly.
However, when I specify the latter charset the W3C validator spits out an error message:
Error: Bad value ISO-8859-1 for attribute charset on element meta: iso-8859-1
Is there a way to get the characters displaying correctly and get a W3C validation, or am I expecting too much?
Regards
Tog
The suggested "already answered" question does not apply because: 1) My php version is 5.4, not 5.5 (2) I do not understand the answer which seems to be aimed at people who have a greater depth of knowledge than me.
OK I think I have the answer now. Thanks to deceze for pointing me to: http://kunststube.net/frontback/
I first checked the database and the fields are set to a collation of; utf8_general_ci, which I presume is correct.
I now have:
<meta charset="utf-8">
at the top of the page and the dbase connection is now:
$dbh = new PDO("mysql:host=$hostname;dbname=$dbname; charset=utf8;", $username, $password);
Adding the charset in there appears to have fixed the problem and the characters now display correctly, whilst the page passes W3C validation.
Many thanks for the help.
Tog