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.