views:

60

answers:

2

I'm trying to place some Chinese text on a website, but as soon as the page is placed online, instead of Chinese text, i see a row of question marks ?????????? ???????????

I tested the same page on a WAMP server before putting it online (all the pages have a php extension) and the Chinese characters show just fine, it is only when the pages are requested from the online host server do i see all the question marks.

the page contains (if this helps):

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+1  A: 

The actual HTTP response headers will always override the HTML <meta> headers. As per your comment:

I'm not too familiar with headers, here is the response header from the working page:

Date: Thu, 24 Jun 2010 05:24:23 GMT 
Server: Apache/2.0.63 (Win32) PHP/5.2.11 
X-Powered-By: PHP/5.2.11 
Content-Length: 3622 
Keep-Alive: timeout=15, max=100 
Connection: Keep-Alive 
Content-Type: text/html; charset=UTF-8 
200 OK
and the non-working page:
Date: Thu, 24 Jun 2010 05:26:54 GMT 
Server: Apache 
X-Powered-By: PHP/5.2.12 
Connection: close 
Transfer-Encoding: chunked 
Content-Type: text/html 
200 OK

See, the HTTP response header of the non-working page has a Content-Type of text/html without any specified charset. It should have been text/html; charset=UTF-8.

You can go around this by adding the following line to the top of your PHP page, before you emit any character (HTML) to the response body.

header('Content-Type: text/html; charset=UTF-8');

Update: as per the comments, the above cause seems to be excluded. Next check; is the file itself saved as UTF-8? Rightclick page and view source. Are the question marks also there? If so, then something went wrong during FTP transfer to the hosting. Choose binary instead of text/ASCII or set character encoding for transferred text files in FTP client settings and retry.

BalusC
Ok, i placed <?php header('Content-Type: text/html; charset=UTF-8'); ?> on the first line of the document, the response header returned Content-Type: text/html; charset=UTF-8, however i still only see question marks
ok, i changed the transfer type to binary, still no lucki checked the page source, and yes, the question marks are still there. when i check the source of the file in cpanel, i can see the cinese text (so the ftp transfer looks fine)
Look like a webserver issue. I'd consult the hosting support.
BalusC
+1  A: 

If you're using a database of some sort, make sure you run this before querying the database (but after making the connection):

mysql_set_charset("utf8");
msakr
there is no database, thanks tho.