diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-05-19 10:17:32 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-05-23 14:53:18 -0700 |
commit | 9bad4be21482d36bff76357a000e008755b60361 (patch) | |
tree | 0b5a96719cb6fd9772ec58b24d84dc62bb4eadfe /src/corelib/text/qstringconverter.cpp | |
parent | 34cb03da89188c8c6566681a2c2548731b007099 (diff) |
QStringConverter: use the QUtf8 codec when Windows is using UTF-8
The QLocal8Bit implementation assumes that there's at most one
continuation byte -- that is, that all codecs are either Single or
Double Byte Character Sets (SBCS or DBCS). It appears to be the case for
all Windows default codepages, except for CP_UTF8, which is an opt-in
anyway.
Instead of fixing our codec, let's just use the optimized UTF-8
implementation.
[ChangeLog][Windows] Fixed support for using Qt applications with UTF-8
as the system codepage or by enabling that in the application's
manifest.
Discussed-on: https://lists.qt-project.org/pipermail/interest/2022-May/038241.html
Pick-to: 6.2 6.3
Change-Id: I77c8221eb2824c369feffffd16f0912550a98049
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/text/qstringconverter.cpp')
-rw-r--r-- | src/corelib/text/qstringconverter.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index 201b1f3f24..d252d7b667 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -1173,6 +1173,11 @@ QChar *QUtf32::convertToUnicode(QChar *out, QByteArrayView in, QStringConverter: } #if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) +int QLocal8Bit::checkUtf8() +{ + return GetACP() == CP_UTF8 ? 1 : -1; +} + static QString convertToUnicodeCharByChar(QByteArrayView in, QStringConverter::State *state) { qsizetype length = in.size(); @@ -1226,7 +1231,7 @@ static QString convertToUnicodeCharByChar(QByteArrayView in, QStringConverter::S } -QString QLocal8Bit::convertToUnicode(QByteArrayView in, QStringConverter::State *state) +QString QLocal8Bit::convertToUnicode_sys(QByteArrayView in, QStringConverter::State *state) { qsizetype length = in.size(); @@ -1314,7 +1319,7 @@ QString QLocal8Bit::convertToUnicode(QByteArrayView in, QStringConverter::State return s; } -QByteArray QLocal8Bit::convertFromUnicode(QStringView in, QStringConverter::State *state) +QByteArray QLocal8Bit::convertFromUnicode_sys(QStringView in, QStringConverter::State *state) { const QChar *ch = in.data(); qsizetype uclen = in.size(); |