curl-and-php
Re: unicode character transport + decoding problems
Date: Sun, 13 Feb 2005 16:54:41 -0700
Sorry. Here's the code:
<?php
header('Content-Type: text/html; charset=UTF-8');
$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
?>
On Sat, 12 Feb 2005 21:29:49 +0500, Brian Wilkins <brian_at_hcc.net> wrote:
> Code snippets?
>
> > Hello,
> > I joined because curl seems to work great for what I'm doing, except
> > I'm having problems with foreign characters turning into "?" question
> > marks. It seems like it could be a user-agent or accept-charset
> > issue, but I'm not certain.
> >
> > Currently, I can see all these websites on my browser but am having
> > problems retrieving them as they come back as "????????".
> >
> > http://www.m3m.ru/export/news/yandex/trans.asp
> > http://www.tamiloviam.com/newsfeed/writerpara.xml
> > http://www.volksmusiknet.ch/34-d365-jk7u2y/index.php
> > http://babelfish.altavista.com/babe...nology&lp=EN_RU
> >
> > Here's the simple PHP code:
> >
> > Should I be setting my headers on the page, or anything else to match
> > the results?
> >
> > I've tried header('Content-Type: text/html; charset=ISO-8859-1') and
> > header('Content-Type: text/html; charset=UTF-8') without luck.
> >
> > Thanks for any ideas.
> > Brian
>
>
Received on 2005-02-14