Results 1 to 3 of 3

Thread: Download a web page to utf8.

  1. #1
    Join Date
    Apr 2009
    Posts
    19
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Download a web page to utf8.

    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:

    Qt Code:
    1. htmlFile = new QFile("downl.html");
    2. htmlFile->open(QIODevice::WriteOnly | QIODevice::Text);
    3.  
    4. QUrl url( "http://images.google.it/images" );
    5. http = new QHttp;
    6. http->setHost(url.host(),url.port() != -1 ? url.port() : 80);
    7.  
    8. http->get(url.path() +"?q=test&gbv=2&hl=it&sa=G&imgsz=small|medium|large|xlarge", htmlFile);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Download a web page to utf8.

    You should try setting the "Accept-Charset" request header to "Accept-Charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7".

  3. #3
    Join Date
    Apr 2009
    Posts
    19
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Download a web page to utf8.

    Thanks but I'm new with QHttp. Can you post an example?

Similar Threads

  1. Download a web page!
    By Faster in forum Newbie
    Replies: 0
    Last Post: 12th April 2009, 13:35
  2. Best way to open a Qt window from web page?
    By montylee in forum Qt Programming
    Replies: 9
    Last Post: 19th January 2009, 08:04
  3. QTabWidget remove a page at the page's request
    By thomaspu in forum Qt Programming
    Replies: 2
    Last Post: 29th December 2007, 20:45
  4. page faults
    By moowy in forum General Programming
    Replies: 2
    Last Post: 20th January 2007, 14:13
  5. QWidget display on 2 stack widget page
    By spawnwj in forum Qt Programming
    Replies: 3
    Last Post: 4th September 2006, 12:07

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.