summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets/code
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-03-03 13:46:50 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2022-03-18 01:22:54 +0100
commite10d613509fb606526fe1a0535dcceb81dbc7840 (patch)
tree20127f07720147be01d393541a68eac7593c8fdd /src/corelib/doc/snippets/code
parente0206fe9d47bfbf18a0d4c2e5e780504305f72e7 (diff)
Add QByteArray::percentDecoded() as an instance method
Percent-decoding was previously only present as a static method taking a QBA parameter; it might as well be an instance method of that parameter. Change most QBA tests to use it rather the static method. [ChangeLog][QtCore][QByteArray] percentDecoded() is now available as an instance method of the byte array to be decoded, equivalent to the static QByteArray::fromPercentEncoding(). Change-Id: I982101c44bdac5cc4041e85598d52ac101d38fa1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/doc/snippets/code')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp b/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp
index d86eb39290..233708d62c 100644
--- a/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_text_qbytearray.cpp
@@ -490,17 +490,22 @@ macAddress.toHex(0); // returns "123456abcdef"
//! [51]
QByteArray text = QByteArray::fromPercentEncoding("Qt%20is%20great%33");
-text.data(); // returns "Qt is great!"
+qDebug("%s", text.data()); // reports "Qt is great!"
//! [51]
//! [52]
QByteArray text = "{a fishy string?}";
QByteArray ba = text.toPercentEncoding("{}", "s");
-qDebug(ba.constData());
+qDebug("%s", ba.constData());
// prints "{a fi%73hy %73tring%3F}"
//! [52]
//! [53]
QByteArray ba = QByteArrayLiteral("byte array contents");
//! [53]
+
+//! [54]
+QByteArray encoded("Qt%20is%20great%33");
+QByteArray decoded = encoded.percentDecoded(); // Set to "Qt is great!"
+//! [54]
}