WordPress Charset Encoding Problem After Upgrading to Version 2.2

WordPress blogs that upgraded to Wordpress version 2.2 may encounter strange character set (charset) encoding problem where several characters especially apostrophes (’), quotation marks (”), and hyphens or dashes (—) are displayed as strange characters such as ’ or simply as question marks (?) when the posts are output to web pages. As you have probably suspected, the issue is caused by character encoding method used by WordPress 2.2 which supports setting of database collation and character set in WordPress config file.

The error happens because up to and including WordPress ver 2.1.3, almost all WordPress databases were created using the latin1 character set and the latin1_swedish_ci collation. Beginning WordPress v2.2, WordPress allows the user to define both the database character set and the collation in wp-config.php file, using DB_CHARSET and DB_COLLATE values. With these values set to another encoding, WordPress assumes that the databases are indeed using the charset and collation too, where it’s not the case for existing WordPress installation. So if you’re upgrading WordPress to 2.2 using the default wp-config.php, or have manually modified the file to include the new variables, or upgrading by using Fantastico which automatically update the wp-config.php file to include these two definitions which values set as Unicode UTF-8 by default, you will need to remove these definitions to solve the character encoding error.

Open and edit your WordPress wp-config.php file. Then locate the following two lines:

define(’DB_CHARSET’, ‘utf8′);
define(’DB_COLLATE’, ”);

You can simply delete these 2 lines away, or just remove the utf8 from the first line to make them looks like this:

define(’DB_CHARSET’, ”);
define(’DB_COLLATE’, ”);

With no charset and collation values set, WordPress will fall back to the old default, latin1 which matched the databases.

A possible better solution is convert the Wordpress database to UTF8 Unicode.


40 Responses to “WordPress Charset Encoding Problem After Upgrading to Version 2.2”

  1. Snigel.nu – Olle Linge » WordPress updated to version 2.8
    July 4th, 2009 05:18
    40

    [...] Update: Chinese and Swedish alike should be displayed properly now. The problem arises when converting to new versions of WorpPress, but by changing a few parameters, it’s possible to let WordPress revert to the old way of handling charactersets. The solution to the problem can be found here. [...]

  2. babysitter
    May 3rd, 2009 11:20
    39

    I solved following these steps:
    http://www.levysoft.it/archivio/2007/07/06/risolvere-il-problema-della-visualizzazione-errata-dei-caratteri-accentati-su-wordpress-cambiando-il-charset-da-iso-8859-a-utf-8/

  3. RaiulBaztepo
    March 29th, 2009 05:14
    38

    Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language ;)
    See you!
    Your, Raiul Baztepo

  4. Marek
    January 31st, 2009 02:33
    37

    Thank you a lot! It worked out perfectly. Now, I have to convert everything to UTF8.

  5. مشاكل الترميز Encoding في Wordpress 2.2 بعد الترقية | سوالف حسن
    December 23rd, 2008 12:49
    36

    [...] WordPress Charset Encoding Problem After Upgrading to Version 2.2 اقرأ المزيد عن …أهلا 2.5، ومرة أخرى مشكلة الترميز بحمدالله تم الانتقال إلى النسخة الحديثة 2.5 من ووردبريس، وكل…ما الجديد! تم اصدار نسخة جديدة من برنامج ووردبريس، وكما ذكر في…WYSI-Wordpress محرر نصوص متقدم Wysi-Wordpress محرر تنسيق المدونات لمن يريد اختيارات أكثر و حرية… [...]

  6. Tommy
    October 17th, 2008 13:15
    35

    Thank you for this post!

  7. Fix odd characters in Wordpress posts | Chris Fay & Jennie Fay’s Webportal
    September 16th, 2008 10:05
    34

    [...] caused due to the encoding and collation, however after following the recommendations of sites like http://www.mydigitallife.info/2007/0…to-version-22/ I was still unable to get rid of the huge amount of garbled characters. Ultimately, I spent some [...]

  8. Paula G
    September 6th, 2008 19:50
    33

    Thanks so much — you saved me hours of hair pulling!

  9. Ates Goral
    August 24th, 2008 11:20
    32

    Thanks! Saved me a lot of time.

  10. Rodrigo
    August 23rd, 2008 05:24
    31

    thanks

  11. Endolith
    June 18th, 2008 08:42
    30

    Isn’t UTF8 much better? Why would you limit yourself to Latin1 just because it used to be the default?

  12. Tom Clarke
    June 6th, 2008 20:56
    29

    Just wanted to say: this had afflicted me for months. Never found a workable solution. Stumbled on your site today and it worked perfectly. Thanks so much!

  13. Josh
    February 19th, 2008 05:04
    28

    Hi, thanks for doing this. it’s the only thing I’ve found. I remove the utf8 and a lot of my posts still have the question marks. any ideas what I may need to do?

  14. Marthin
    February 17th, 2008 03:44
    27

    thanks for the help, it worked out for me :)

  15. Bruno Silva
    January 5th, 2008 06:55
    26

    Thx a lot!
    You saved me hours!

  16. Back on track! | isa costa * the geek side
    November 19th, 2007 03:31
    25

    [...] de upgrade (localizado em wp-admin/upgrade.php), os posts apareciam com os acentos todos marados. A solução mais rápida é editar o ficheiro wp-config.php e deixar os valores das constantes DB_CHARSET e [...]

  17. cgb
    October 27th, 2007 03:18
    24

    thanks!

  18. morgan
    October 21st, 2007 09:39
    23

    Thank you so much for this. It fixed the error.

  19. Marco Polci » Blog Archive » Wordpress e set di caratteri
    September 19th, 2007 20:10
    22

    [...] questo post viene spiegato il problema e presentata una soluzione. In realtà nel mio caso il problema sembra [...]

  20. WordPress Line Break Problem | W-Shadow.com
    September 15th, 2007 01:59
    21

    [...] also applied a charset encoding hack to my wp-config.php. All this combined solved my line break problem. Share and Enjoy: These icons [...]

  21. Websitetology » WordPress displaying odd characters?
    August 31st, 2007 03:18
    20

    [...] this excellent article will give you the answers you need to your broken WordPress install: WordPress Charset Encoding Problem After Upgrading to Version 2.2 » My Digital Life WordPress blogs that upgraded to Wordpress version 2.2 may encounter strange character set [...]

  22. Small Frame Code
    August 31st, 2007 03:14
    19

    [...] You can read more about the problem, and the solution, at MyDigitalLife. [...]

  23. Vladimir
    August 30th, 2007 08:48
    18

    Thanks a lot! It works! :)

  24. Mark’s (we)Blog » Mark’s (we)Blog 2.0
    August 30th, 2007 04:37
    17

    [...] fixed that issue (commenting out define(’DB_CHARSET’, ‘utf8′); and define(’DB_COLLATE’, ”);) – further explanation of this fix can be found at My Digital Life although I haven’t been brave enough to convert the character set and collation [...]

  25. Pelles Blog » Arkiv » S� har man uppdaterat
    August 13th, 2007 03:23
    16

    [...] Editerat: Nu hittade jag vad det handlade om, om du råkat ut för samma sak, kolla här. [...]

  26. curo.dk » Blog Archive » Updated site
    August 11th, 2007 22:31
    15

    [...] found something here but it does not seem to work for my [...]

  27. sandstorm » Blog Archive » Problemino aggiornando WP alla 2.2.1 e nuova grafica
    July 29th, 2007 04:24
    14

    [...] trovato in particolare questo ottimo post che mi ha permesso risolvere il problema in 5 secondi, è bastato modificare un parametro nel file [...]

  28. Wrong charset when upgrading wordpress to 2.2 : Just a blog thingie
    July 24th, 2007 20:46
    13

    [...] Long version can be found at this site [...]

  29. colin
    July 17th, 2007 13:55
    12

    You are awesome. We need more people like you here on Earth.

  30. commadot.com » Blog Archive » Fantastico Upgrade of WordPress
    July 14th, 2007 10:26
    11

    [...] was panicking when I saw that my database had these characters EVERYWHERE.  Then I found this great article on the subject. It clearly states how to fix the problem.  Thank goodness.  I was totally going to make things [...]

  31. iHassan.com
    July 11th, 2007 06:23
    10

    [...] WordPress Charset Encoding Problem After Upgrading to Version 2.2 [...]

  32. Kryptoblog » Blog Archive » Wordpressuppdatering och åäö
    July 2nd, 2007 21:26
    9

    [...] 2007-07-02) Josef tipsade om den här länken. Lite fix med ftp senare så är vi nästan tillbaka på banan [...]

  33. Messier Hunter
    July 2nd, 2007 04:00
    8

    God Bless You, Man!!!

  34. AvengerBR » Update para o Wordpress 2.2 x Erros de Acentua
    June 29th, 2007 06:57
    7

    [...] posts, mas como tenho mais 3 blogs isso era um problema. Dando uma procurada no Google, achei este post que resolveu isso. A solu

  35. Pablo Rosales
    June 27th, 2007 22:31
    6

    Thanks!! You save my blog :D

  36. Greg
    June 27th, 2007 09:16
    5

    Man, thank you, don’t know why I didn’t think of that before – I has going insane – appreciate it.

  37. WooHoo
    June 24th, 2007 23:54
    4

    Awesome, thanks so much!

  38. ckunte.com | UTF-8 and Wordpress 2.x
    June 24th, 2007 19:40
    3

    [...] My Digital Life explains in detail about the problem I experienced (see also the Trac and the Codex) and a (temporary) workaround—this worked for me, by the way. But if you’re not a fan of latin1 character set and associated latin1_swedish_ci collation, then I’d recommend this UTF-8 database converter plugin. Run once, it’s painless—this worked for me too, except for non-english characters (like if you used the caret ones natively in posts and or pages). [...]

  39. How to Convert Character Set and Collation of WordPress Database » My Digital Life
    June 23rd, 2007 03:36
    2

    [...] Since WordPress 2.2, WordPress supports feature that allows the user to define both the WordPress database character set and collation with DB_CHARSET and DB_COLLATE values in wp-config.php file. With these values defined, WordPress will use the designated database characterset (charset) and database collation (i.e. sort order of the letters, numbers, and symbols of a character set) when connecting a database tables. However, in existing WordPress installations that are upgraded from earlier version of WordPress or not explicitly set a Unicode UTF-8 charset collation, the default database character set is normally set up as Latin1 (default on almost all MySQL installation) with latin1_swedish_ci collation. If you run a bilingual or multilingual blog with WordPress, you may face problem on character encoding when your blog posts are written in other foreign languages, or when you export and backup the database and later attempt to re-import the database dump in the event of database failure or server migration and moving. The symptom is obvious, your WordPress posts or pages will contains garbled, weird and funny characters, sometime just lots of ????? (question marks), rendering the WordPress database with your hard work useless and output unreadable. (May cause also by wrong charset collation) [...]

  40. pigduck
    June 19th, 2007 22:35
    1

    Thank you lifesaver!

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

wordpress charset - wordpress character encoding - wordpress encoding - utf-8 wordpress - wordpress and encoding - wordpress DB_CHARSET - encoding wordpress - wordpress character unicode problem - wordpress charset problem - after upgrading wordpress utf-8 is not working - Encoding for pages wordpress - wordpress theme functions weird characters - strange characters wordpress - wordpress mysql arabic encoding character problems - charset magyar - wordpress encodeui - wordpress character problem - carriage return not working wordpress - character problems wordpress - encoding for php files wordpress - greek encoding question marks wordpress - mysql export to rss utf-8 problems with åäö - swedish charset +wordpress - which encoding for swedish+wordpress - wordpress problem with spanish charset - wordpress upgrade, weird characters - wordpress charset error - wordpress feed encoding ? - wordpress  characters - DB_COLLATE for spanish - magyar charset - ou est le charset wordpress - wordpress apostrophes question marks - wordpress strange signs - wordpress fix utf-8 - wordpress rss charset issue - wordpress utf-8 problem - charset wordpress - char set в wordpress - page encoding in wordpress - vista charset problem - wordpress character encoding problem - wordpress character \x96 -  utf wordpress - unable to upgrade wpau wp-security scan - utf-8 character set + outlook 2007 - wordpress "default charset" - wordpress change encoding - wordpress + charset + iso 55 - wordpress utf-8 -