0

I'm getting strange characters in my fresh local WAMP installation. I've just downloaded all .php files from ftp online and restored a backup on my local mysql server. The problem only happens when text contains symbols or special characters:

enter image description here

PHP: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

MySQL collation: latin1_swedish_ci

In this image of course there is a strange symbol "°" where "°" and "€" are needed. This has happened both in Opera and Firefox.

Any idea? Thanks for helping, as always.

gremo
  • 47,186
  • 75
  • 257
  • 421
  • 1
    See for instance http://stackoverflow.com/questions/7501924/php-messing-with-html-charset-encoding – Fabio Sep 23 '11 at 00:17
  • Do the php files have some of these characters in them? You may need to download and upload them in binary mode instead of ascii mode. That could have corrupted certain characters in your files. – drew010 Sep 23 '11 at 00:19
  • @Fabio why should i change the encoding while the site is perfectly working online?drew010 i will check FileZilla, but most of the text (like in picture) come from database, not from php itself. – gremo Sep 23 '11 at 00:26
  • Your edit shows why you're experiencing this, the reason is the `latin1_swedish_ci` collation. See my answer on how to fix it. – Fabio Sep 23 '11 at 00:40

1 Answers1

0

I'll answer here because it's too long for a comment.

You don't need to change your encoding, you should check your encoding. Keep in mind that encoding could be changed in a lot of different places:

Any of these reasons could lead to wrong encoding displayed in the web browser. And if you do not specify it with one or more the previous methods, the corresponding layer will use its configured default.

In your case since the text is coming from database and since often in WAMP/XAAMP/MAMP MySQL use a weird default encoding, I'd check for point one. Try to execute SET NAMES UTF-8 (or whatever encoding you use) query before retrieving data, just after your db connect function.

Fabio
  • 18,856
  • 9
  • 82
  • 114
  • Got it. I've changed the collation for the table (wp_posts... wordpress one) to utf8_general_ci, but nothing has changed. Now i'm thinking that the problems comes from BigDump script i've used to restore 200M+ database... can be? – gremo Sep 23 '11 at 00:52
  • @Gremo maybe, but have you tried to execute in some way the `SET NAMES UTF-8` query after your connection? If that is a wordpress database try also this [google search](http://www.google.com/search?q=wordpress%20change%20mysql%20encoding) – Fabio Sep 23 '11 at 01:00