I've a problem with encoding on german website. I have a text:
„Eröffnungsfeier FIS Alpine Ski WM 2011“
When this text is saved into database I get ? instead of those quotes.
I've tried placing
header("Content-Type: text/html; charset=utf-8");
mb_internal_encoding("UTF-8");
setlocale(LC_ALL, 'de_DE.utf-8');
On the top of the file without success.
When I've used
mysql_set_charset('utf8', $connect);
But then, when inserting text above after reaching first character like ö the rest of the text is stripped.
The table charset and collation is UTF-8. Script file is saved as UTF-8 without BOM.
I lack of ideas where to look.
/etc/locales.gen
, uncomment whatever you want, then locale-gen
as root), it happened to me many times :- - Victor Nițu 2012-04-06 00:50
The things I did helped. Especially mysql_set_charset('utf8', $connect);
.
The problem was that there was some unwanted code left by another programmer (utf8_decode).
Looks like he couldn't deal with utf-8 encoding other way.
I've also found out that mysql_set_charset('utf8', $connect);
is not really needed if you're consistent with the encoding from the beginning.
1) Check the schema of your database - are the text fields set up to store utf-8?
2) It sounds like the page posting to this script is not sending UTF-8. Does it have the correct Content-Type
header? What does echo urlencode($var)
show? (that's a neat hack to see the raw bytes you're getting)