qt5base-lts/tests/auto/corelib/text
Fabian Kosmale 122270d6be Long live the ICU-based QStringConverter interface!
This adds support for additional codecs to QStringConverter when ICU is
available.

We store the converter in the state (d[0]), and its canonical name in
d[1]. We need the name there, as in the clear function we close the
UConverter, and set the pointer to null. Consequently, the actual
conversion functions might need to re-open the converter again. The
advantage of this approach is that clear is used in the destructor of
State, and with this approach we properly clean up the state.
There is however a disadvantage: The clear function was so far also used
for resetting the state when QStringConverter::resetState . Discarding
the whole Uconverter for that is however rather costly. For that reason
we modify resetState to call a new function, State::reset. For existing
converters, it behaves the same as clear; for the ICU based converter,
we call the more efficient ucnv_reset. Code compiled against Qt 6.4 can
benefit from this more efficient version; code compiled against older Qt
versions will continue to work, as the conversion functions can just
recretate the converter from the name.
We can distinguish between ICU and non-ICU converters by checking if the
UsesIcu flag is set.

QStringConverter::name is changed to return the name stored in d[1]. The
interface of the ICU converter has a dummy name, so code using the old
name function from QT < 6.4 still returns something, namely a message
asking the user to recompile.
The function is moved out of line, as we need to check for the private
ICU feature, and want to avoid having that check in the public header.

As the QStringConverter ctor taking a name now can allocate memory, it
can no longer be noexcept. Removing the noexceptness is safe, as it was
only added after Qt 6.3.

Note that we cannot extend the API consuming or returning Encoding, as
we use Encoding values to index into an array of converter interfaces in
inline API.

Further API to support getting an ICU converter for HTML will be added
in a future commit.

Currently, the code depending on ICU is enabled at compile time if ICU
is found. However, in the future it could be moved into a plugin to
avoid a hard dependency on ICU in Core.

[ChangeLog][Corelib][Text] QStringConverter and API using it now
supports more text codecs if Qt is compiled with ICU support.

Fixes: QTBUG-103375
Change-Id: I7afb92fc68ef994179ebc7a3aa73beebb1386204
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-19 00:41:12 +02:00
..
qanystringview tst_QAnyStringView: explicitly check the spaceship operator 2022-06-14 01:30:48 +00:00
qbytearray Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qbytearrayapisymmetry Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qbytearraylist Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qbytearraymatcher Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qbytearrayview Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qbytedatabuffer Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qchar Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qcollator Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qlatin1stringview Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qlocale Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qregularexpression Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qstring Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qstring_no_cast_from_bytearray Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qstringapisymmetry tst_QStringApiSymmetry: use QCOMPARE_EQ instead of QCOMPARE 2022-06-03 20:37:51 +00:00
qstringbuilder Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qstringconverter Long live the ICU-based QStringConverter interface! 2022-06-19 00:41:12 +02:00
qstringiterator Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qstringlist Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qstringmatcher Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qstringtokenizer Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qstringview Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qtextboundaryfinder tst_qtextboundaryfinder: Remove full copies of data files 2022-05-24 23:07:43 +02:00
qunicodetools Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
shared Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
CMakeLists.txt Android: Enable building of the QLocale test case 2022-05-23 19:12:06 +00:00