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.
Related posts:
- WordPress 2.2 Released for Free Download
- Download Previous or Old Version of WordPress
- WordPress 2.1.1 Critical Security Alert – Download Upgrade to 2.1.2
- How to Customize, Modify or Change WordPress Database Connection Error Page
- 3 Column Relaxation WordPress Theme comments-paged.php for Paged-Comments WordPress Plugin





Thanks..this worked
THANKS A LOT!
HELP!!!
I am using WP latest version, with Exec-php plugin (to run php code) and TTF plugin (to convert text with any font to images).
My fonts has all special chars but whenever I enter á é í etc it is replaced by a box.
I'm using UTF-8 for posts, is there any extra config I should take into account?
Thanks in advance!
I never look forward to a WordPress upgrade. Seems there is always a glitch of some sort. Your post helped me quickly fix this one.
Thanks very much.
I had a similar problem with a wp update but sorted it out alright. Think I did the update the wp database to UTF8 Unicode.
[...] 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. [...]
I solved following these steps:
http://www.levysoft.it/archivio/2007/07/06/risolv…
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
Thank you a lot! It worked out perfectly. Now, I have to convert everything to UTF8.
[...] WordPress Charset Encoding Problem After Upgrading to Version 2.2 اقرأ المزيد عن …أهلا 2.5، ومرة أخرى مشكلة الترميز بحمدالله تم الانتقال إلى النسخة الحديثة 2.5 من ووردبريس، وكل…ما الجديد! تم اصدار نسخة جديدة من برنامج ووردبريس، وكما ذكر في…WYSI-Wordpress محرر نصوص متقدم Wysi-Wordpress محرر تنسيق المدونات لمن يريد اختيارات أكثر و حرية… [...]
Thank you for this post!
[...] 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 [...]
Thanks so much — you saved me hours of hair pulling!
Thanks! Saved me a lot of time.
thanks
Isn't UTF8 much better? Why would you limit yourself to Latin1 just because it used to be the default?
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!
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?
thanks for the help, it worked out for me
Thx a lot!
You saved me hours!
[...] 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 [...]
thanks!
Thank you so much for this. It fixed the error.
[...] questo post viene spiegato il problema e presentata una soluzione. In realtà nel mio caso il problema sembra [...]
[...] also applied a charset encoding hack to my wp-config.php. All this combined solved my line break problem. Share and Enjoy: These icons [...]
[...] 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 [...]
[...] You can read more about the problem, and the solution, at MyDigitalLife. [...]
Thanks a lot! It works!
[...] 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 [...]
[...] Editerat: Nu hittade jag vad det handlade om, om du råkat ut för samma sak, kolla här. [...]
[...] found something here but it does not seem to work for my [...]
[...] trovato in particolare questo ottimo post che mi ha permesso risolvere il problema in 5 secondi, è bastato modificare un parametro nel file [...]
[...] Long version can be found at this site [...]
You are awesome. We need more people like you here on Earth.
[...] 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 [...]
[...] WordPress Charset Encoding Problem After Upgrading to Version 2.2 [...]
[...] 2007-07-02) Josef tipsade om den här länken. Lite fix med ftp senare så är vi nästan tillbaka på banan [...]
God Bless You, Man!!!
[...] posts, mas como tenho mais 3 blogs isso era um problema. Dando uma procurada no Google, achei este post que resolveu isso. A solu
Thanks!! You save my blog
Man, thank you, don't know why I didn't think of that before – I has going insane – appreciate it.
Awesome, thanks so much!
[...] 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). [...]
[...] 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) [...]
Thank you lifesaver!