5#include "private/qstringconverter_p.h"
6#include "private/qtools_p.h"
7#include "private/qsimd_p.h"
99 0xff, 0xff, 0xff, 0xff, 0xff,
100 0xff, 0xff, 0xff, 0xff, 0xff,
109 0xff, 0xff, 0xff, 0xff, 0xff,
110 0xff, 0xff, 0xff, 0xff, 0xff,
111 0xff, 0xff, 0xff, 0xff, 0xff,
112 0xff, 0xff, 0xff, 0xff, 0xff,
113 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
121 0xff, 0xff, 0xff, 0xff, 0xff,
122 0xff, 0xff, 0xff, 0xff, 0xff,
123 0xff, 0xff, 0xff, 0xff, 0xff,
124 0xff, 0xff, 0xff, 0xff, 0xff,
125 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
136 return (
c >= u
'a' &&
c <= u
'f') || (
c >= u
'A' &&
c <= u
'F') || (
c >= u
'0' &&
c <= u
'9');
152 return c >= u
'a' ?
c - u
'a' + 0xA :
c >= u
'A' ?
c - u
'A' + 0xA :
c - u
'0';
160 char16_t c1 =
input[1];
180 int spaceNeeded =
end -
begin + 2 * charsRemaining +
add;
181 int origSize =
result.size();
182 result.resize(origSize + spaceNeeded);
185 output =
const_cast<char16_t *
>(
reinterpret_cast<const char16_t *
>(
result.constData()))
190 for (
i = 0;
i < charsProcessed; ++
i)
221 static const bool allowNonCharacters =
false;
256 const char16_t *&
input,
const char16_t *
end,
char16_t decoded)
258 char32_t ucs4 = 0, *
dst = &ucs4;
260 int charsNeeded = QUtf8Functions::fromUtf8<QUrlUtf8Traits>(decoded,
dst,
src,
end);
283 const char16_t *&
input,
const char16_t *
end,
char16_t decoded)
295 int charsRemaining =
end -
input - 1;
296 int pos =
output -
reinterpret_cast<const char16_t *
>(
result.constData());
297 int spaceRemaining =
result.size() -
pos;
298 if (spaceRemaining < 3*charsRemaining + 3*utf8len) {
303 output =
const_cast<char16_t *
>(
reinterpret_cast<const char16_t *
>(
result.constData()));
323 c = 0x80 | (
uchar(decoded >> 6) & 0x3f);
329 c = 0x80 | (decoded & 0x3f);
337 QUrl::ComponentFormattingOptions encoding,
const uchar *actionTable,
338 bool retryBadEncoding)
340 const int origSize =
result.size();
342 char16_t *
output =
nullptr;
352 if (c < 0x20U || c >= 0x80U)
364 if (
c ==
'%' && retryBadEncoding) {
371 }
else if (
c ==
'%') {
379 if (decoded >= 0x80) {
387 }
else if (decoded >= 0x20) {
396 }
else if (decoded >= 0x80) {
433 int len =
output -
reinterpret_cast<const char16_t *
>(
result.constData());
435 return len - origSize;
449 const __m256i percents256 = _mm256_broadcastw_epi16(_mm_cvtsi32_si128(
'%'));
450 const __m128i percents = _mm256_castsi256_si128(percents256);
452 const __m128i percents = _mm_set1_epi16(
'%');
462 __m256i
data = _mm256_loadu_si256(
reinterpret_cast<const __m256i *
>(
input +
offset));
463 __m256i comparison = _mm256_cmpeq_epi16(
data, percents256);
464 mask = _mm256_movemask_epi8(comparison);
468 __m128i data1 = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
input +
offset));
469 __m128i data2 = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
input +
offset + 8));
470 __m128i comparison1 = _mm_cmpeq_epi16(data1, percents);
471 __m128i comparison2 = _mm_cmpeq_epi16(data2, percents);
472 uint mask1 = _mm_movemask_epi8(comparison1);
473 uint mask2 = _mm_movemask_epi8(comparison2);
475 _mm_storeu_si128(
reinterpret_cast<__m128i *
>(
output +
offset), data1);
477 _mm_storeu_si128(
reinterpret_cast<__m128i *
>(
output +
offset + 8), data2);
478 mask = mask1 | (mask2 << 16);
492 __m128i
data = _mm_loadu_si128(
reinterpret_cast<const __m128i *
>(
input));
493 __m128i comparison = _mm_cmpeq_epi16(
data, percents);
494 mask = _mm_movemask_epi8(comparison);
495 _mm_storeu_si128(
reinterpret_cast<__m128i *
>(
output),
data);
499 __m128i
data = _mm_loadl_epi64(
reinterpret_cast<const __m128i *
>(
input));
500 __m128i comparison = _mm_cmpeq_epi16(
data, percents);
501 mask = _mm_movemask_epi8(comparison) & 0xffu;
502 _mm_storel_epi64(
reinterpret_cast<__m128i *
>(
output),
data);
545 const char16_t *
begin =
in.utf16();
555 const int origSize = appendTo.
size();
568 memcpy(
static_cast<void *
>(appendTo.
begin() + origSize),
575 if (
output[-1].unicode() >= 0x80)
582 const char16_t uc = *
input;
593 return len - origSize;
599 for (
size_t i = 0;
i < N; ++
i)
639 QUrl::ComponentFormattingOptions encoding,
const ushort *tableModifications)
652 if (tableModifications) {
653 for (
const ushort *
p = tableModifications; *
p; ++
p)
654 actionTable[
uchar(*
p) -
' '] = *
p >> 8;
657 return recode(appendTo,
reinterpret_cast<const char16_t *
>(
in.begin()),
658 reinterpret_cast<const char16_t *
>(
in.end()), encoding, actionTable,
false);
static constexpr QChar fromUcs2(char16_t c) noexcept
static constexpr bool requiresSurrogates(char32_t ucs4) noexcept
Returns true if the UCS-4-encoded character specified by ucs4 can be split into the high and low part...
static constexpr char16_t highSurrogate(char32_t ucs4) noexcept
Returns the high surrogate part of a UCS-4-encoded code point.
static constexpr char16_t lowSurrogate(char32_t ucs4) noexcept
Returns the low surrogate part of a UCS-4-encoded code point.
constexpr bool isHighSurrogate() const noexcept
Returns true if the QChar is the high part of a UTF16 surrogate (for example if its code point is in ...
\macro QT_RESTRICTED_CAST_FROM_ASCII
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first character in the string.
void truncate(qsizetype pos)
Truncates the string at the given position index.
qsizetype size() const
Returns the number of characters in this string.
QChar * data()
Returns a pointer to the data stored in the QString.
void resize(qsizetype size)
Sets the size of the string to size characters.
Combined button and popup list for selecting options.
constexpr char toHexUpper(char32_t value) noexcept
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t * qustrchr(QStringView str, char16_t ch) noexcept
constexpr uint qCountTrailingZeroBits(quint32 v) noexcept
static ControlElement< T > * ptr(QWidget *widget)
GLboolean GLboolean GLboolean b
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLenum GLenum GLenum input
GLenum GLenum GLsizei void * table
static void add(QPainterPath &path, const QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define Q_AUTOTEST_EXPORT
static const uchar defaultActionTable[96]
static char16_t decodePercentEncoding(const char16_t *input)
static bool encodedUtf8ToUtf16(QString &result, char16_t *&output, const char16_t *begin, const char16_t *&input, const char16_t *end, char16_t decoded)
Q_AUTOTEST_EXPORT qsizetype qt_urlRecode(QString &appendTo, QStringView in, QUrl::ComponentFormattingOptions encoding, const ushort *tableModifications)
static bool simdCheckNonEncoded(...)
static int recode(QString &result, const char16_t *begin, const char16_t *end, QUrl::ComponentFormattingOptions encoding, const uchar *actionTable, bool retryBadEncoding)
static ushort decodeNibble(char16_t c)
static char16_t encodeNibble(ushort c)
static char16_t toUpperHex(char16_t c)
static bool isUpperHex(char16_t c)
static const uchar reservedMask[96]
static void maskTable(uchar(&table)[N], const uchar(&mask)[N])
static void unicodeToEncodedUtf8(QString &result, char16_t *&output, const char16_t *begin, const char16_t *&input, const char16_t *end, char16_t decoded)
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 isHex(char16_t c)
QT_BEGIN_NAMESPACE typedef uchar * output
static uchar peekByte(const uchar *ptr, qsizetype n=0)
static void appendByte(uchar *&ptr, uchar b)
static void advanceByte(const uchar *&ptr, qsizetype n=1)
static qptrdiff availableBytes(const uchar *ptr, const uchar *end)