5

I have a problem regarding special characters that are appearing messed up on the front-end . mainly the get converted to question marks, or something like �?)

Example - Frédèric becomes Fr�d�ric.

some facts that made me puzzled:

  • This WP install is on LOCAL machine, and shares the server with at
    least 40 other installs - none of which have this problem.

  • This WP install shares also the same DB as the others .

  • My wp-config file has the collate and charset defined.

  • The DB seems fine , because when I am viewing the post in the EDITOR (back end) - all is correct , the problem is only on the FRONT end .

    • The DB seems fine (2) , opening the post in phpMyAdmin and checking the direct value - all characters are fine .
  • This problem is NOT a browser/os encoding , it was checked in 4
    different machines, 3 OS, and 9 browsers..

I have tried all the solutions which I know from past experience, which include :

  • checking the wp-config (it is ok, utf-8 defined, collate ok)
  • Checking the DB - all UTF-8
  • checking my header (<?php bloginfo('charset'); ?>) - that renders correctly as utf-8 with valid markup.
  • Open all theme files in my editor, convert encoding to UTF-8 without bom and save.

Did i missed something ? Any Ideas ??

  • And your files are written/saved in UTF-8 (Themes, Plugins)? – kaiser Jan 8 '12 at 5:23
  • 1
    yep - I already wrote it in the question itself. UTF-8 without BOM – user13279 Jan 8 '12 at 5:23
  • You wrote "Theme", not plugins. Sure you have deactivated all plugins? – kaiser Jan 8 '12 at 5:24
  • no. I did not deactivated any plugins, because none are installed (well, maybe askimet or hello dolly - but not activated) – user13279 Jan 8 '12 at 6:06
  • 2
    Why the tag htmlspecialchars-decode? Does the problem happen with TwentyEleven too? – fuxia Jan 8 '12 at 16:14
2

Edit:

Do you have <meta charset="utf-8" /> in your <head> tag? A user here fixed a similar problem with character encoding by adding this.

There are actually many Google results that come up searching for utf-8 character encoding in wordpress.

Also, does pasting the text into the HTML view of the editor and saving it make any difference?


Below is not such a good idea as @toscho explained in comments.

I am not sure if this is the best method to fix the problem but this worked for one of my clients' websites.

Find these two lines in your wp-config.php file:

define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

And comment them out like so:

//define('DB_CHARSET', 'utf8');
//define('DB_COLLATE', '');
  • 1
    Now you risk to get mixed saved encodings. Not a good idea. – fuxia Feb 20 '12 at 20:24
  • @toscho Correct, I'm poking around the web for a better solution and will update my answer soon. – Jared Feb 20 '12 at 20:28
  • <meta charset="utf-8" /> Adding this worked form me. – Rahul Aug 17 '17 at 7:46
0

Are you using htmlentities() to escape your output by any chance? If so you need to define 'UTF-8' as the third parameter.