homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

cannot display Chinese characters
not because of <meta>

 10:42 pm on Jul 16, 2009 (gmt 0)

Hi, I'm trying to set up a Chinese web page in my school's server. The page is written in PHP and I did use

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

to make sure that the characters are encoded. I tried it on localhost on my laptop and it works perfectly (the Chinese characters are displayed properly).

The problem is that when I upload the page folder onto the server, the characters cannot be displayed; there are some funny-looking scribbles like this:


but the page works fine.

Does anything know what the problem is? Thank you!



 9:49 am on Jul 17, 2009 (gmt 0)

welcome to webmasterworld

some ideas:
create a file with phpinfo() in it and run it. Check HTTP_ACCEPT_CHARSET to verify that server accepts utf-8 (most likely) and/or chinese charsets

are you pulling data from a mysql database? If yes, make sure that your db can accept chinese charsets OR that the data are in chinese chars stored there

- you can force your db to use an encoding with these two lines:
mysql_query("SET character_set_connection=english");
mysql_query("SET character_set_client=english");

Put those (and take a look at mysql manual for those) right below your mysql_select_db() line and use the appropriate charset for you


 2:40 pm on Jul 17, 2009 (gmt 0)

Thanks for your reply. I have checked the server and it accepts utf-8. I'm not pulling data from mysql database. It's a very short simple survey so I wrote everything in the php page and stored the data in a text file.

Do you know what else could be the reason?


 3:34 pm on Jul 17, 2009 (gmt 0)

I am also facing the same problem with my Urdu pages.

Have someone good suggestions?


 6:45 pm on Jul 17, 2009 (gmt 0)

I know the answer now (thanks to a wonderful colleague!). In the folder, create a .htaccess file with this line:

AddDefaultCharset UTF-8

and voila, it works!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved