Qt does not encode the "+" sign

Why doesn't Qt5 encode the plus sign in% 2B?

I tried this code:

QUrlQuery urlQuery;
urlQuery.addQueryItem("test", "hello+world");
manager->post(request, urlQuery.toString(QUrl::FullyEncoded).toUtf8());

But on the server side, you always get a line like:

hello world

without% 2B and unsigned plus. Therefore, I can not get the "+" sign on the server side ...

How can I send a plus sign with Qt5?

+4
source share
1 answer

How can I send a plus sign with Qt5?

Do not use URL for data post, use QByteArray. It will be sent as is.

EDIT

Additional information for QUrlQuery, the + sign is a special case (from the document):

Handling spaces and plus ("+")

- , HTML FORM, ( "+" ) (% 2B). , URL-, . QUrlQuery "+" "+" . "%20" . , HTML-, QUrlQuery "%2B" . , "%2B" "+" , , , , ( "%2B" "%2B" ).

, QUrlQuery , +, , ("+" = > "%2B"), QUrl::toPercentEncoding().

+3

All Articles