Re: opening utf-8 files - chinese mb characters
| From: | Paul Gregg | Date: | Wed, 08 Apr 2009 17:13:44 +0000 |
| Subject: | Re: opening utf-8 files - chinese mb characters | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-291233@lists.php.net to get a copy of this message | ||
In mail.php.general, Merlin Morgenstern <merlin_x@fastmail.fm> 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 do:
>
> $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);
You don't want this.
> header("Content-Type: text/html; charset=utf-8");
You do want this.
> But still... no luck :-(
>
> Has somebody an idea why??
Try it with just the Content-Type: header addition.
header('Content-Type: text/html; charset=UTF-8');
Regards,
PG