[Qt-interest] PHP's htmlentities in Qt

Karol Krizka kkrizka at gmail.com
Fri Jul 24 12:56:53 CEST 2009


On Thu, 2009-07-23 at 22:26 +0300, frgtn wrote:
> Don't know about html_entity_encocde/decode equivalents in Qt, but you 
> can use XML CDATA sections. You can put the text between <![CDATA[ <..> 
> ]]> and contents will not be parsed by XML parser.
> 
> One downside of it is that you'll have to check for "]]>" sequence anyway.
> 
Thank you very much, that worked pretty well for now. I just had to do
some extra processing to make sure ]]> is always escaped. Basically, I
convert every & into an &amp; and then convert every > into &gt;. I
think that's basically htmlentities would have done, but with just
having to take care of less symbols.

--
Cheers,
Karol Krizka
http://www.krizka.net



> Karol Krizka wrote:
> > Hi there,
> > 
> > I'm wondering if there is a function in Qt that is equivalent to PHP's
> > htmlentities [1] and html_entity_decode [2]. One basically turns all
> > special HTML characters into entities, and the other one reverses that.
> > 
> > The reason I am asking this is that I'm trying to save an HTML document
> > inside an XML file. The HTML document is some text and images that the
> > user will create, and the XML file is a global settings file that will
> > contain the said document. I need to encode the HTML special characters
> > (<,>,&) into something that will make it possible for me to reread the
> > entire document back from the XML file without any trouble.
> > 
> > --
> > Cheers,
> > Karol Krizka
> > http://www.krizka.net
> > 
> > [1] http://ch2.php.net/manual/en/function.htmlentities.php
> > [2] http://ch2.php.net/manual/en/function.html-entity-decode.php
> > 
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
> > 
> 




More information about the Qt-interest-old mailing list