[Qt-interest] URL encoding only non-printing characters

Thiago Macieira thiago at kde.org
Wed Apr 7 20:12:28 CEST 2010


Em Quarta-feira 07 Abril 2010, às 19:13:19, Bob Hood escreveu:
> I'm displaying string values a QListView.  These string values can
> contain anything, but in particular, non-printing characters within the
> string cause the grief with the display; e.g., a carriage-return
> character will cause the display of the string to end abruptly at the
> point where it appears.
> 
> Although these strings are not URLs, I have encoded the string using
> QUrl::toPercentEncoding(), and that "normalizes" it so that it displays
> completely (albiet with URL-encoded percent values) in the QListView.
> However, I would rather encode only non-printing characters.  Others,
> like "?" or "{", are fine for my purposes.
> 
> Would anybody have an idea how I could specify non-printing characters
> (line-feed, tab, etc.) in the combination of toPercentEncoding()'s
> "include" and "exclude" settings such that only those values are percent
> encoded?

http://doc.qt.nokia.com/4.6/qurl.html#toPercentEncoding

The extra parameters to toPercentEncoding indicate which characters to include 
or exclude in the encoding. The example itself shows how to make { } not be 
encoded.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100407/a1d69d63/attachment.bin 


More information about the Qt-interest-old mailing list