PDA

View Full Version : Download a web page to utf8.



Faster
13th April 2009, 14:43
When I download a web page with QHttp the page downloaded is not in utf8. How can I convert the page in utf8?

This is my code:



htmlFile = new QFile("downl.html");
htmlFile->open(QIODevice::WriteOnly | QIODevice::Text);

QUrl url( "http://images.google.it/images" );
http = new QHttp;
http->setHost(url.host(),url.port() != -1 ? url.port() : 80);

http->get(url.path() +"?q=test&gbv=2&hl=it&sa=G&imgsz=small|medium|large|xlarge", htmlFile);

marcel
13th April 2009, 14:46
You should try setting the "Accept-Charset" request header to "Accept-Charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7".

Faster
13th April 2009, 20:49
Thanks but I'm new with QHttp. Can you post an example?