qt6-bb10/tests/auto/corelib/serialization
Thiago Macieira d4c7da9a07 CBOR: fix sorting of UTF16-to-UTF16 strings
This amends commit 394788c68e (its
ChangeLog applies to this commit too). That fixed sorting of UTF8-to-
UTF16, but when adding more unit tests, I've discovered that some UTF-16
strings also sorted incorrectly. There were two problems:

First, we were assuming that we could rely on the UTF-16 length as a
proxy for the UTF-8 one, but that's not true for some cases:
* both 1-, 2- and 3-codepoint UTF-8 sequences are 1 codepoint
  in UTF-16, so some strings would have identical UTF-16 length
* 4-codepoint UTF-8 sequences shrink to 2-codepoint UTF-16 ones
  (2:1) but 3-codepoint UTF-8 sequences shrink to 1 (3:1), so
  some strings would be longer in UTF-16 but shorter in UTF-8.

Second, QtPrivate::compareStrings performs UTF-16 codepoint comparisons
not Unicode character ones, so surrogate pairs were sorting before
U+E000 to U+FFFF.

To fix all of this, we need to decode the UTF-16 string into UTF-32 and
calculate the length of that in UTF-8 to be sure we have the sorting
order right.

Since this is a slight behavior change with a performance penalty, I am
choosing to backport only to 6.7. The penalty mostly does not apply to
6.8 due to commit 61556627f2.

Pick-to: 6.7
Change-Id: If1bf59ecbe014b569ba1fffd17c4c4ddcc874aac
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-12 21:41:16 -07:00
..
json QJsonObject iterators: use new comparison helper macros 2024-04-12 19:31:51 +02:00
qcborstreamreader QCborStreamReader: rename toStringish() -> readAllStringish() 2024-03-12 05:36:54 +01:00
qcborstreamwriter Change license for tests files 2024-02-04 09:56:42 +01:00
qcborvalue CBOR: fix sorting of UTF16-to-UTF16 strings 2024-04-12 21:41:16 -07:00
qcborvalue_json Change license for tests files 2024-02-04 09:56:42 +01:00
qdatastream Tests: check the output of QFile::open 2024-03-27 04:24:11 +01:00
qdatastream_core_pixmap Change license for tests files 2024-02-04 09:56:42 +01:00
qtextstream Tests: check the output of QFile::open 2024-03-27 04:24:11 +01:00
qxmlstream Tests: make some QFile::open calls fail 2024-04-13 01:36:06 +02:00
CMakeLists.txt wasm tests: Disable unstable qcborvalue test 2023-11-23 19:26:49 +01:00
cborlargedatavalidation.cpp Change license for tests files 2024-02-04 09:56:42 +01:00