Results 1 to 5 of 5

Thread: Special character's HTML entity to string

  1. #1
    Join Date
    Dec 2007
    Posts
    6

    Question Special character's HTML entity to string

    I have a set of HTML files, that are used in 2 different ways in my program: I have QTextBrowser for displaying the HTML pages normally inside my program and I parse manually header information from these files in order to display the information in a completely separate list.

    The problem is, that the language in these files contains special characters, that are encoded as HTML entities, for example:
    Qt Code:
    1. <h1>teku&#263;ina</h1>
    To copy to clipboard, switch view to plain text mode 

    This is displayed correctly on my QTextBrowser, but in the separate list this is parsed wrong: I simply read this line with standard getLine() to std:string, so the string will contain the
    Qt Code:
    1. &#263;
    To copy to clipboard, switch view to plain text mode 
    instead of ć.

    Is there any easy way around this, like how to convert these HTML entities to QString? Or would the better option to edit the HTML files somehow to contain the actual character ć instead of the entity, without breaking the QTextBrowser functionality?

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Special character's HTML entity to string

    I simply read this line with standard getLine() to std:string
    where r u reading the line from?

  3. #3
    Join Date
    Dec 2007
    Posts
    6

    Default Re: Special character's HTML entity to string

    Quote Originally Posted by talk2amulya View Post
    where r u reading the line from?
    From the *.html files, I read every line actually, but I'm interested only of the string inside the h1-tags. This is completely separate from the QTextBrowser functionality I have currently, and my point bringing it up was that the same HTML files must work on both cases.

  4. #4
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Special character's HTML entity to string

    i dont think that would be possible, perhaps you would need to put a hack by reading the content into a QTextEdit using setHtml, read out of it using toHtml() into a string, then parse through it. all this time u will need QTextEdit only for sm time, and u can destroy it as soon as u have read back from it so it wont create any hassle. But if you come up with a better solution, let us know

  5. #5
    Join Date
    Dec 2007
    Posts
    6

    Default Re: Special character's HTML entity to string

    I was in a bit of hurry so I brute forced it and made a conversion function, that changes the HTML entities to correct characters (I manually mapped them, the language in question did not have too many special characters).

Similar Threads

  1. Special characters in Html blocks
    By giusepped in forum Qt Programming
    Replies: 4
    Last Post: 27th October 2008, 09:13
  2. Problem at time compilation in traslation of language
    By thomasjoy in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2007, 15:18

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.