View Full Version : Encode document to Chinese (UTF8)

02-07-2006, 01:11 PM
Hi. I have a PHP file that is interpreted at run-time bringing together 4 or 5 include files. Most of these files (with extentions "tpl" and "inc") are either ANSI encoded or UTF-8 encoded.

I have tried in the HEADER include file to change the encoding to UTF-8 by adding:

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

But this doesn't help... I still have to MANUALLY change Internet Explorer / Firefox settings by clicking on VIEW -> ENCODING -> UNICODE (UTF8) in order to have the correct display, otherwise it comes out a garbled mess.

Please see this (http://langues.p-maps.org/pmaps/subscribe_info.php?sess_is_visitor=1&lan=cn) to understand what I am talking about.

I don't want the user to manually change the encoding... how to make it automatic?


Rich Pedley
02-07-2006, 03:17 PM
Not sure how to make it automatic, but I would strongly suggest that all files are of the type utf-8 rather than mixing them.

I believe you may have to send the following header:

Content-Type: text/html; charset utf-8

http://www.w3.org/International/tutorials/tutorial-char-enc/ has more info on the subject.

However the pages displayed fine for me, even though the browser picked up the wrong type!

02-07-2006, 03:35 PM
I have set the header for the entire document by altering the meta tag of the header include file (which should logically be universal for the entire post rendered HTML file).

Unless you mean altering the actual PHP header file.


header("Content-Type: charset=utf-8");

...other php code...


Is this what you mean? I tried that... didnt work either.

Rich Pedley
02-07-2006, 08:27 PM
it was, but I'll admit that was a pure guess.

Looks like it is possibly a server issue, have a look at:
which may be useful.

I now recall that a server where I maintain a site recently changed an apache setting to serve all pages as utf-8. made it easier for me, though you still have to ensure that all the files are saved as utf-8 and not ansi or anything else.