View Full Version : Encoding/decoding a string to URL and HTML

25th September 2010, 22:14
Are there any methods in Qt allowing programmer to easily encode/decode a string to URL and HTML?

Examples of what I need:

URL encoding:
"abc def" → "abc%20def"
URL decoding:
"abc%20def" → "abc def"

HTML encoding:
"A&B&C" → "A&B&C"
HTML decoding:
"A&B&C" → "A&B&C"

Of course these are trivial examples. I need full support for URL and HTML standards.

It seems HTML can be en/decoded using a QTextEdit::plainText and QTextEdit::html. But this requires QtGui and is not a nice solution at all.

25th September 2010, 22:17
QUrl (http://doc.trolltech.com/4.7/qurl.html#details) reference (it's in core)

25th September 2010, 22:19
Thanks. I just have found this.

And what about the HTML encoding?

25th September 2010, 22:32
As far as i know that is in Gui module.

25th September 2010, 22:40
HTML encoding can be done with QTextDocument. Yet it's still QtGui.