![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include "qurl.h"#include "private/qurl_p.h"#include "private/qstringconverter_p.h"#include "private/qtools_p.h"#include "private/qsimd_p.h"Go to the source code of this file.
Enumerations | |
| enum | EncodingAction { DecodeCharacter = 0 , LeaveCharacter = 1 , EncodeCharacter = 2 , DecodeCharacter = 0 , LeaveCharacter = 1 , EncodeCharacter = 2 } |
| enum | EncodingAction { DecodeCharacter = 0 , LeaveCharacter = 1 , EncodeCharacter = 2 , DecodeCharacter = 0 , LeaveCharacter = 1 , EncodeCharacter = 2 } |
Functions | |
| static bool | isHex (char16_t c) |
| static bool | isUpperHex (char16_t c) |
| static char16_t | toUpperHex (char16_t c) |
| static ushort | decodeNibble (char16_t c) |
| static char16_t | decodePercentEncoding (const char16_t *input) |
| static char16_t | encodeNibble (ushort c) |
| static void | ensureDetached (QString &result, char16_t *&output, const char16_t *begin, const char16_t *input, const char16_t *end, int add=0) |
| static bool | encodedUtf8ToUtf16 (QString &result, char16_t *&output, const char16_t *begin, const char16_t *&input, const char16_t *end, char16_t decoded) |
| static void | unicodeToEncodedUtf8 (QString &result, char16_t *&output, const char16_t *begin, const char16_t *&input, const char16_t *end, char16_t decoded) |
| static int | recode (QString &result, const char16_t *begin, const char16_t *end, QUrl::ComponentFormattingOptions encoding, const uchar *actionTable, bool retryBadEncoding) |
| static bool | simdCheckNonEncoded (...) |
| static bool | isUnsafeForLocalFile (uchar byte) |
| static qsizetype | decode (QString &appendTo, QStringView in, QUrl::ComponentFormattingOptions encoding) |
| template<size_t N> | |
| static void | maskTable (uchar(&table)[N], const uchar(&mask)[N]) |
| Q_AUTOTEST_EXPORT qsizetype | qt_urlRecode (QString &appendTo, QStringView in, QUrl::ComponentFormattingOptions encoding, const ushort *tableModifications) |
| qsizetype | qt_encodeFromUser (QString &appendTo, const QString &in, const ushort *tableModifications) |
Variables | |
| static const uchar | defaultActionTable [96] |
| static const uchar | reservedMask [96] |
| enum EncodingAction |
| Enumerator | |
|---|---|
| DecodeCharacter | |
| LeaveCharacter | |
| EncodeCharacter | |
| DecodeCharacter | |
| LeaveCharacter | |
| EncodeCharacter | |
Definition at line 14 of file qurlrecode.cpp.
| enum EncodingAction |
| Enumerator | |
|---|---|
| DecodeCharacter | |
| LeaveCharacter | |
| EncodeCharacter | |
| DecodeCharacter | |
| LeaveCharacter | |
| EncodeCharacter | |
Definition at line 14 of file qurlrecode.cpp.
|
static |
This function decodes a percent-encoded string located in in by appending each character to appendTo. It returns the number of characters appended. When the encoding mode is QUrl::FullyDecoded (the mode used for most functions), each percent-encoded sequence is decoded as follows:
\list
Given the above, it's important for the input to already have all UTF-8 percent sequences decoded by qt_urlRecode (that is, the input should not have been processed with QUrl::EncodeUnicode).
The input should also be a valid percent-encoded sequence (the output of qt_urlRecode is always valid).
With QUrlDecodeForLocalFile in encoding, the function instead returns -1 when it would decode a byte that is unsafe in a local-file path. The appendTo string is truncated back to its original size, but always returns null if the original was empty.
If no decoding error happened, this function returns the number of characters added to appendTo. That might be 0 if there was nothing to decode (see qt_urlRecode() below for the reason).
Definition at line 573 of file qurlrecode.cpp.
References isHex().
|
inlinestatic |
Definition at line 152 of file qurlrecode.cpp.
|
inlinestatic |
Definition at line 160 of file qurlrecode.cpp.
References isHex().
Referenced by recode().
|
static |
Definition at line 257 of file qurlrecode.cpp.
|
inlinestatic |
Definition at line 169 of file qurlrecode.cpp.
|
static |
Definition at line 174 of file qurlrecode.cpp.
|
inlinestatic |
Definition at line 136 of file qurlrecode.cpp.
Referenced by decode(), and decodePercentEncoding().
|
static |
Definition at line 530 of file qurlrecode.cpp.
|
inlinestatic |
Definition at line 141 of file qurlrecode.cpp.
Referenced by recode(), and toUpperHex().
Definition at line 646 of file qurlrecode.cpp.
| qsizetype qt_encodeFromUser | ( | QString & | appendTo, |
| const QString & | in, | ||
| const ushort * | tableModifications ) |
Definition at line 720 of file qurlrecode.cpp.
References defaultActionTable, and EncodeCharacter.
| Q_AUTOTEST_EXPORT qsizetype qt_urlRecode | ( | QString & | appendTo, |
| QStringView | in, | ||
| QUrl::ComponentFormattingOptions | encoding, | ||
| const ushort * | tableModifications ) |
Recodes the string from begin to end. If any transformations are done, append them to appendTo and return the number of characters added. If no transformations were required, return 0.
The encoding option modifies the default behaviour: \list
Other flags are ignored (including QUrl::EncodeReserved).
The tableModifications argument can be used to supply extra modifications to the tables, to be applied after the flags above are handled. It consists of a sequence of 16-bit values, where the low 8 bits indicate the character in question and the high 8 bits are either EncodeCharacter, LeaveCharacter or DecodeCharacter.
This function corrects percent-encoded errors by interpreting every '' as meaning "%25" (all percents in the same content), except in Decoded modes.
On success, this function returns the number of characters added to appendTo, or -1 on error (errors are currently only detected if encoding is QUrlDecodeForLocalFile). A return value of 0 means this function had no percent-encoded transformations to perform, so the caller must append the in input to appendTo. This lets the caller return a shallow copy of the original QString (avoiding allocation) and keep control of its null-vs-empty state.
Definition at line 697 of file qurlrecode.cpp.
|
static |
Definition at line 340 of file qurlrecode.cpp.
References DecodeCharacter, decodePercentEncoding(), EncodeCharacter, isUpperHex(), LeaveCharacter, and toUpperHex().
|
static |
Definition at line 520 of file qurlrecode.cpp.
|
inlinestatic |
Definition at line 147 of file qurlrecode.cpp.
References isUpperHex().
Referenced by recode().
|
static |
Definition at line 286 of file qurlrecode.cpp.
|
static |
Definition at line 26 of file qurlrecode.cpp.
Referenced by qt_encodeFromUser().
|
static |
Definition at line 83 of file qurlrecode.cpp.