Andrew Ballard wrote:
On Wed, Apr 8, 2009 at 11:38 AM, Per Jessen <> wrote:
Merlin Morgenstern wrote:

Hello everybody,

I am having some trouble with utf-8 encoding. The html file containes
chinese characters and looks ok, when opened in a browser.

Now I want to extract some text from the file. In order to do this I

$handle = fopen($file, "r");
$contents = fread($handle, filesize($file));

echo $contents;

The chinese characters are gone by then. They show up as questinomarks
or wired characters. To fix it I tried to add:

$contents = utf8_decode($contents);
header("Content-Type: text/html; charset=utf-8");

But still... no luck :-(

Has somebody an idea why??
Check that the page really is displayed with the right encoding - in FF,


Per Jessen, Zürich (16.6°C)

A bit off topic, but Ctrl+I no longer brings up the Page Info in
Firefox like it used to -- at least on my Windows computers. (It opens
the bookmark list in the sidebar.) Does it do differently under Linux?


I use windows right click for this.

Actually I isolated the problem, but still I can't figure out how to solve it. The page is not utf-8, but ugb2312.

I am already sending the header through php:
header("Content-Type: text/html; charset=ugb2312");

And with apache http.conf:
AddDefaultCharset ugb2312

However firefox still claims that it is utf-8 which is causing the strange characters.

What a night mare! Does anybody have an idea on how to get closer to solving this?

Regards, Merlin

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to