diff options
| author | Marc Mutz <marc.mutz@qt.io> | 2024-05-27 09:48:06 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2024-08-03 00:34:15 +0000 |
| commit | d897e6a5f37a8ddd99d6d1cfe2b91e14a3dfdeed (patch) | |
| tree | d9e28c3b478f20c05b2f5eb7a9fba81331348662 /src/widgets/doc/snippets/graphicsview/graphicsview_snippet.cpp | |
| parent | 39fa7e7bef90be2940c5f736935f963e3969e0bd (diff) | |
QAnyStringView: fix (char) ctor producing an invalid UTF-8 sequence
While Qt expects const char* to be UTF-8, existing APIs treat a single
char as a L1 character, incl. QChar(char) and QString::arg(char).
Even char8_t literals are only allowed to contain US-ASCII content,
therefore are a subset of L1. Fix the detection of encoding
to treat all 1-byte characters as L1 and the rest as UTF-16.
This restores consistency with overload sets including QChar, and the
intention of the original author. While treating char(0xE4) as a
malformed UTF-8 sequence can theoretically be argued for, that
behavior would be useless in practice.
This change does not affect sliced()/first()/last(), nor front() and
back().
[ChangeLog][QtCore][QAnyStringView] Fixed a bug where a QAnyStringView
constructed from `char` would produce an invalid UTF-8 sequence
instead of a valid Latin-1 one, as expected from the equivalent QChar
constructor.
Fixes: QTBUG-125730
Change-Id: I8cacdd4af4b101db1c2c5797c49fe35a30abdc79
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/widgets/doc/snippets/graphicsview/graphicsview_snippet.cpp')
0 files changed, 0 insertions, 0 deletions
