I previously had some problems when I mixed Unicode with WordPress. Every time I typed a Unicode character, (after posting) it would display as a ‘?’. This post will describe how to fix this.
Basically, the problem is that WordPress is not comprehending this, and instead of telling the database to store the Unicode characters, it just says, “Heck, just stick a bunch of question marks in there.”
Of course, this can be easily fixed in two steps. All you’ll need is FTP access to your server and a fair comprehension of how to type. So, let’s get started!
- Open up ‘wp-config.php’ from the root directory of your WordPress installation.
- Add ‘//’ at the very beginning of these two lines:
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
So that section should now look like this:
//define('DB_CHARSET', 'utf8');
//define('DB_COLLATE', '');
You’re already finished. How easy was that?
Important notes:
- The quotes surrounding // in step 2 should not be inserted. Those are just indicating that the // is the part you should insert.
- If you’ve meddled with that part of ‘wp-config.php’ before, it may look a bit different. But pay no attention to the differences. Just be sure add // to the lines containing
DB_CHARSETandDB_COLLATE.
Did you find this article useful? Please leave a comment to let me know. Don’t worry, you don’t need to register for a simple comment.
Looks to me like you’re going a long way round here. My computer just does Unicode unless I tell it to do something else. A few programs still come with Latin 3 or even Latin 1 by default but you can easily change this is the ‘Tools’. Or am I missing something?
But, it isn’t avilable for vietnamese
But by default WordPress won’t parse Unicode characters correctly. At least with Esperanto characters, that’s what I used to try it..
Pretty awesome article. Thanks! – CowDir
thank you so so so much for this… i wasted an hour trying to fix till i found your post and then violla… FIXED
Are you kidding me?!? After hours of trying to figure out what in the blazes was going on, all it took was a few //s? Incredible. You are a genius in my mind. Thanks!
it worked without making this change… for malayalam…
I was pulling my hair on this one – the source code for the web page says that WordPress IS doing Unicode – but it isn’t. Bill Gates to thank for why this is a problem only on some computers.
I am so glad to fix this after only one day.
Actually, you fixed it.
Thanks!
(If you think Bush is bad, wait’ll you see what’s next…)
Wonderful insight. This made such a huge difference to the effort I was putting to get this working.
Thank you so much. You are making the blog a wonderful learning and sharing tool.
Thanks a lot,its so easy n working.
Thanks once again.:)
keep goin!!
Thanks. There must be a reason why unicode is not enabled by default. I was very puzzled initially because the upper characters would display properly while editing the post initially. Only later did I find that they were converted to ???s when I saved/published the post. That was the clue that led me to your post.
I’ll be reading more of your site – thanks for documenting your insights!
David
i want to create blog with khmer language.
can u help me, how to do?
dfsdffffsdfsf
Thanks! It was very helpful!
Just surfing the web and found your site,I am also involved with people search and background checks.Your site has been really helpful thanks.
Thank you very very much dear, I was strugulling lot to fix this problem, how easily you described, thanks lot,
Awesome, my site in in the maori language using macrons etc. Yours is a tip i’ll no doubt use time and time again
Thanks! (Unless WP fixes it for us?!?!?)
i tried making such change and reviwed twice to make sure, i didnt commit any mistake..
its not working for me. i just started developing a website and you may see it ..the demo on http://blogprahari.in
i wish to show hindi unicode characters.. and the same ? ? ?????
signs appear.. please help me at earliest.
ooh!
it did .. but for the newer posts I made..
it didnt work for the earlier posts..
Thanks a lot..
I had this same problem – couldn’t get my new blog to show Unicode characters. Then I figured out where the problem is. I just wanted to share it here for future reference.
At the time of installing WP, in the config file the following settings need to be present
define(‘DB_CHARSET’, ‘utf8′);
define(‘DB_COLLATE’, ‘utf8_general_ci’);
By default the collate setting is left as ”.
That is the problem. In the MySQL database tables that wordpress creates, all the table fields will be left as default collation which is the ‘latin1_swedish_ci’ .
This causes an inconsistency. You are writing UTF8 chars into a latin collation. so the data gets lost(turns to ‘???’)
So if you are installing fresh, make sure you set both the settings.
Now as suggested here, when you comment out the first DB_CHARSET setting, then you will be using a ASCII and latin collation combo which works. (because, you are no longer storing the data as Unicode – they will be stored as some funky characters – something like à°°à°¾à ±‡…)
And, another point, no matter what you do, you will not be able to get your UTF8 data once its corrupted.(ie. when they turn to “???” and not these -”à°° ±‡” ).
Hope this helps.
-V
simple but effective!! thanks
Omg.. was it that easy o.o cheers!
Great tip, solved my problems with Serbian characters šđčćž
Sir!
I have the similar “??? ” problem with my wp installation I made using fantastico installer. I used your trick and it made the things go perfect. Now I upgraded the installation script, had the same error ( characters were now “-”à°° ±‡”). I again repeated the trick, but it made partial correction with the display. Still some posts have the similar ???? problem.
help me out please!
I’ve have been stumbled this issues for a long time. The two line code works like a magic. Thank you.
When you are recreating your blog from an import XML file, Do this modification and then import.
You know I tried this method and it worked, but it caused issues all over my site in other posts. It started to mess up apostrophes and such. Any recommendations?
The same thing happened to me, Adam. When I went back to the old wp-config file, it was even worse. What did you end up doing?
Thank you so very, very much!
Thanks.
Its working for me. I am searching for this from last many days.for my website http://www.gujaratisms.com for Gujarati Language.You help me out.
Thanks again.
thank you very much! Now my blog works great!
this work fine. But the problem is
define(‘DB_CHARSET’, ‘utf8′);
is an essential line.If u commented it you cannot use your database for do any other work.
Best way is , when creating a database make collation to either
utf8_general_ci or utf8_unicode_ci. Both work same manner except sorting method. cheers
thank u for a great problem solve. it worked for our site accurately,
thanking is not enough for this
thanks for the solution! it actually works for the posts, but I still have this bug on the main page…i’m stonned
You are God!Thanks so much!!!
Thanks Dude, you solve my problem so easily, I was searching for this problem for an hour over google. Thanks Again
Thanks
You solved my problem –YEEEHAW!
Perfect fix, very simple step. Despite I wonder what is the implication of removing these two lines, will the db not know what charset to use? or sth else?
Tried it, but it made all these diamond shaped question marks after every period. Weird… back to searching the web for a different solution I guess
I had problems with this too, Todd. I have a lot of Spanish text on my site and any Spanish character where there’s an accent or tilde is now corrupt, even though I am now able to post new material in Hebrew just fine. I also wasn’t able to reverse the damage that this “fix” did. What did you end up doing?
hai , i did this. but not fixed.
and tell me one more thing.how can i change wordpress site’s dash boadrd interface language? that means i want full telugu wordpress.
Thank you for sharing the blog. I look forward to many more interesting articles.
thank a lot
Fab! You were the last ‘find’ before I gave up. Worked a treat and in seconds. Thank You!
Thank you so much! I was having the same problem in Latvian language. And now I have fixed it finally. So THANK YOU!
hi, atlast fixed my problem through this method. thank a lot.
Thanks! What an easy fix – I wonder why that’s not default.
thanx a lot man…that really worked for me
I am very lucky to find your web site. Your article is very useful. Thank you for share
I think your article is very useful for me. Thanks
I think this might be a short-sighted solution. The problem may be that your database tables are defined with a different encoding. In my case, they were mysql tables with “latin1″ encoding. I changed their encodings (using mysqldump, an editor, and mysql < dumpfile) and now they are properly encoded in UTF-8.
Alan
Thank you.
This solved my problem.
Simple solution for A BIG PROBLEM.
Yes, worked for me. Thanks a lot.
Thank you very-much!!!!! This world works because of you nice people who like helping others…
Thank you very much.
I am able to create a wordpress website in gujarati
Thanks! I was going nuts with some articles a writer had sent me!
Thank’s alot for your Great information….
It helps many people with this problem…
Dennis Tran
Well, this is certainly my problem too & apparently it has been around for a long time. I know nothing about php, but when I open the wp-config file I find that the two lines of code you suggest are already there, though they come after the <php? tag at the beginning of the file & do not have the // in front of them, nor are they the first MySql strings in the file. To my untrained eye, the // looks like in precedes comments in the file and that actual code does not begin with //
Anyhow, before I edit the file, I'm looking for a bit of reassurance that this is what I should be doing. A couple of other notes: I use a configurable keyboard set for unicode that uses VIQR input & it works in every application I can find, except my WP blog.
Tôi muốn viết Tiếng Việt làm quốc ngữ !
Thanx, i can use it to write nepali as well.
http://www.milonweb.co.cc milons art gallery
Really Thanks, it worked…
Hi there, just became aware of your blog through Google, and found that it
is truly informative. I am gonna watch out
for brussels. I’ll appreciate if you continue this in future. Many people will be benefited from your writing. Cheers!
Thank You, Thank You a lot. It helped me so much. Thanks Thanks Thanks! I was going nuts because of the ?
Hi there! This article could not be written much better!
Reading through this article reminds me of my previous roommate!
He constantly kept talking about this. I will forward this post to him.
Fairly certain he’s going to have a very good read. I appreciate you for sharing!
Lifesaver !!! Thanks a Lot