curl-and-php
Re: unicode character transport + decoding problems
Date: Wed, 23 Feb 2005 08:21:54 +0000
I just tried your script and it seems to work. I commented out the USERAGENT
and HTTPHEADER lines and it brings the data fine. exactly as in the page. Now
when it gets output to my browser it gets shown as western charset, I would
just need to send a header to say its utf-8. Dont remember the exact syntax
for sending headers. you might need to look it up.
n.
Brian Lucas (blucasco_at_gmail.com) wrote:
>
> I wasn't sure if anybody had taken a look at this issue, but I was
> still looking for any ideas people might have where my text encoding
> is getting screwed up -- is it a curl header issue or is php mangling
> the multi-byte variable somehow?
>
> All I want to know is if anybody can grab a feed like
> http://www.tamiloviam.com/newsfeed/writerpara.xml and display it
> properly on their browser. I also tried setting the same headers I
> received from LiveHTTPHeaders into curl and still can't pull it.
>
> simple test code below:
>
> <?php
>
> $url ="http://www.tamiloviam.com/newsfeed/writerpara.xml";
> $ch = curl_init(); // initialize curl handle
>
> curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; FreeBSD
> i386; en-US; rv:1.2a) Gecko/20021021");
>
> curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
>
> curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
>
> curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Charset:
> ISO-8859-1,utf-8;q=0.7,*;q=0.7'));
>
> $result = curl_exec($ch); // run the whole process
>
> echo $result; //contains response from server
> ?>
>
Received on 2005-02-23