PHP Classes

Content encoding problem -need UTF-8

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  Content encoding problem -need UTF-8  >  (Un) Subscribe thread alerts  
Subject:Content encoding problem -need UTF-8
Summary:It looks like the class is not handling some content encoding
Messages:3
Author:Diego Gullo
Date:2010-04-23 14:25:24
Update:2010-04-26 07:58:16
 

  1. Content encoding problem -need UTF-8   Reply   Report abuse  
Picture of Diego Gullo Diego Gullo - 2010-04-23 14:25:25
Hi

I have just installed and tested the http client but like in other packages when the content returned is displayed its encoding is all wrong.

For instance

url: http://news.google.com/news?ned=el_gr&output=rss

this shows an RSS that contains greek letters but when this is displayed from the client

widgets.bizmate.biz/googlenews/http ...

the content is corrupt and unreadable at least for the Greek letters.
Is this a bug or do you think there is something wrong here?

  2. Re: Content encoding problem -need UTF-8   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2010-04-25 07:13:28 - In reply to message 1 from Diego Gullo
There seems to be a misunderstanding. This class just retrieves streams of bytes that the Web servers return as responses to HTTP requests.

It is the browser that you use that displays those bytes as characters. The same sequence of bytes may represent different characters in different idioms. It depends on the character encoding that you specify. That defines which characters correspond to each byte sequence.

If you retrieve some bytes via HTTP and display them in a Web page, you need to tell the browser what is the character encoding used by the page, using for instance the Content-Type header.

If the character encoding is UTF-8, just execute this line of code before outputting the data retrieved from the page:

Header('Content-Type: text/html; charset=utf-8');

Alternatively you can achieve the same effect by inserting a line like this in your HTML page output <head> section:

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

  3. Re: Content encoding problem -need UTF-8   Reply   Report abuse  
Picture of Diego Gullo Diego Gullo - 2010-04-26 07:58:16 - In reply to message 2 from Manuel Lemos
Hi Manuel,

thanks a lot for the reply. Obviously I was using it the wrong way.

Now i can see the text correctly.

Thanks again

Diego