Details
-
Suggestion
-
Resolution: Fixed
-
P3: Somewhat important
-
None
-
None
-
5
-
eaabd0c5450ad849e24878d38dd05d5b23d7eec3
-
Team B Foundation Sprint 53
Description
Currently, as per Qt policy, const char* are treated as being encoded in UTF-8. But most such strings are actually US-ASCII, and therefore valid Latin-1. QAnyStringView, which can contain both, should scan the string at construction time for any 8th-bit character, and having found none, adjust the UTF-8 tag to Latin1. This should be a compile-time check only, no runtime code, so it naturally only applies when some form of string literal is being passed.
Acceptance criteria: The following tests (and others, with constexpr input) pass:
static_assert(QAnyStringView("Hello, World").isLatin1()); static_assert(QAnyStringView(u8"Hello, World").isLatin1()); static_assert(QAnyStringView::fromArray("Hello, World").isLatin1()); static_assert(QAnyStringView::fromArray(u8"Hello, World").isLatin1());
(isLatin1()) is private API atm; we could make the test a friend of QAnyStringView or use
any.visit([](auto view) { return std::is_same_v<decltype(view), QLatin1String>; })
)
Attachments
Issue Links
- relates to
-
QTBUG-134136 Complete Q*StringView literals
-
- Open
-
For Gerrit Dashboard: QTBUG-101014 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
399817,14 | QAnyStringView: constexpr detect 8-bit ASCII as Latin 1 | dev | qt/qtbase | Status: MERGED | +2 | 0 |
426526,2 | [docs] QAnyStringView: mention automatic U8→L1 reclassification | dev | qt/qtbase | Status: MERGED | +2 | 0 |
427917,2 | [docs] QAnyStringView: mention automatic U8→L1 reclassification | 6.4 | qt/qtbase | Status: MERGED | +2 | 0 |