qt5base-lts/tests/auto
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
..
bic/data Add BiC data for the new way to do BiC testing 2022-05-12 13:33:41 +03:00
cmake Fix memory leaks 2022-06-15 23:58:16 +02:00
concurrent QtConcurrent: prevent conversion of ReduceOption to initial value 2022-05-20 17:11:15 +02:00
corelib Long live the ICU-based QStringConverter interface! 2022-06-19 00:41:12 +02:00
dbus QDBusArgument: ensure std::vector isn't seen as an associative container 2022-05-17 01:27:33 +02:00
gui Work around lavapipe bug in tst_qvulkan 2022-06-16 17:29:36 +00:00
guiapplauncher Move QStateMachine from QtCore to QtScxml 2020-08-24 20:10:25 +02:00
network QNetworkReply: Fix the test compilation 2022-06-10 20:57:19 +00:00
opengl Remove the qmake project files 2021-01-07 15:32:28 +01:00
other Accessibility: don't emit focus change when reason is window activation 2022-06-16 19:29:36 +02:00
printsupport 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
sql Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
testlib FatalSignalHandler: print the signal name on crash 2022-06-08 20:39:18 +00:00
tools Teach qmake about digit-grouping apostrophes in numeric literals 2022-06-17 00:05:53 +02:00
widgets Update window state in QWindowsWindow and QXcbWindow geometry setters 2022-06-17 18:59:22 +00:00
xml Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
CMakeLists.txt Only configure one test for wasm 2022-05-12 18:55:04 +02:00
network-settings.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00