Solved: Drupal Cannot Display Chinese Characters (Unicodes)

Filed in: Open Source, Tips, Web Development — May 12th, 2008

I have a community site powered by Drupal but it cannot display chinese characters, even though it supports unicode by default.

All non-English characters are displayed as question marks (???). I tried to reinstall Drupal but without any luck. Yesterday, I finally discovered the problem and solved it!

The problem

Last time, I installed Drupal using the cPanel Fantastico script installer. The installer created database using Latin collation. That’s why Drupal cannot display Chinese characters because the database is not unicode (UTF-8).

Lesson learned: Do not install script using cPanel Fantastico.

The solution

The solution is simple, correct the tables’ collation to UTF-8 using the following SQL query (thanks to neo_fox):

ALTER TABLE table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

I ran the query using phpMyAdmin found in cPanel hosting control panel. But the drawback is that you need to run the SQL query for every single table…

I modified 20+ tables and it works! Now my friends can leave chinese message on the community website. :D

Like this post? Please share:

Tags: ,

Follow me on Twitter and Facebook. Subscribe to free newsletter for updates like this article..

  • http://www.geckoandfly.com/ Gecko

    What is the address of the site? would like to see what mr.liew is up to.

  • http://www.geckoandfly.com Gecko

    What is the address of the site? would like to see what mr.liew is up to.

  • LcF

    Just a private community site for friends to rant. Nothing serious there ;)

  • LcF

    Just a private community site for friends to rant. Nothing serious there ;)

  • http://www.hanep.org/ hanep

    good info. thou’ im not going to use the chinese characters, but this helps me handling php scripts out there. thanks

  • http://www.hanep.org hanep

    good info. thou’ im not going to use the chinese characters, but this helps me handling php scripts out there. thanks

  • http://mobile.islikethat.com/ Alien TYC

    I think wordpress has this problem as well. Have not fix my wordpress yet so that I can blog in chinese..

  • http://mobile.islikethat.com Alien TYC

    I think wordpress has this problem as well. Have not fix my wordpress yet so that I can blog in chinese..

  • LcF

    @Alien TYC: wordpress has a different solution. Check out “Fix Wrong Encoding after Upgrade WordPress 2.2

  • LcF

    @Alien TYC: wordpress has a different solution. Check out “Fix Wrong Encoding after Upgrade WordPress 2.2

  • macrunch

    I m your friend?what is the site URL?

  • macrunch

    I m your friend?what is the site URL?

  • http://www.morzeustka.pl/ noclegi Ustka

    It’s not working for me;/ Maybe I’m doing something wrong but what?

  • http://www.morzeustka.pl noclegi Ustka

    It’s not working for me;/ Maybe I’m doing something wrong but what?

  • somedude

    Thx dude! This article help me to solve same problem with russian language!

  • somedude

    Thx dude! This article help me to solve same problem with russian language!

t
<-- viglink -->