mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
refactor: Remove Qt5 compatibility layer
This commit is contained in:
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
@@ -108,7 +108,7 @@ jobs:
|
||||
uses: jurplel/install-qt-action@v4
|
||||
with:
|
||||
version: ${{ env.qt_version }}
|
||||
modules: 'qtmultimedia qt5compat'
|
||||
modules: 'qtmultimedia'
|
||||
cache: true
|
||||
- name: Cache InstallBuilder
|
||||
id: cache-bitrock
|
||||
@@ -201,7 +201,7 @@ jobs:
|
||||
uses: jurplel/install-qt-action@v4
|
||||
with:
|
||||
version: ${{ env.qt_version }}
|
||||
modules: 'qtmultimedia qt5compat'
|
||||
modules: 'qtmultimedia'
|
||||
arch: win64_msvc2022_64
|
||||
cache: true
|
||||
- name: Install Qt debug info
|
||||
@@ -299,7 +299,7 @@ jobs:
|
||||
uses: jurplel/install-qt-action@v4
|
||||
with:
|
||||
version: ${{ env.qt_version }}
|
||||
modules: 'qtmultimedia qt5compat'
|
||||
modules: 'qtmultimedia'
|
||||
cache: true
|
||||
- name: Cache InstallBuilder
|
||||
id: cache-bitrock
|
||||
|
||||
@@ -87,7 +87,7 @@ if(MSVC)
|
||||
endif()
|
||||
|
||||
# Find dependencies
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core DBus Gui Multimedia Network OpenGL Concurrent Xml Qml Widgets Svg Test Core5Compat)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core DBus Gui Multimedia Network OpenGL Concurrent Xml Qml Widgets Svg Test)
|
||||
|
||||
# Global compiler options
|
||||
if(MSVC)
|
||||
|
||||
@@ -52,7 +52,6 @@ if(UNIX AND NOT APPLE)
|
||||
|
||||
|
||||
installLib(${QT_INSTALL_LIBS} libQt6Core.so.6)
|
||||
installLib(${QT_INSTALL_LIBS} libQt6Core5Compat.so.6)
|
||||
installLib(${QT_INSTALL_LIBS} libQt6DBus.so.6)
|
||||
installLib(${QT_INSTALL_LIBS} libQt6Gui.so.6)
|
||||
installLib(${QT_INSTALL_LIBS} libQt6Multimedia.so.6)
|
||||
|
||||
@@ -46,7 +46,7 @@ set(SWIFT_MISC_PCH
|
||||
<QString>
|
||||
<QStringBuilder>
|
||||
<QStringList>
|
||||
<QStringRef>
|
||||
<QStringView>
|
||||
<QThread>
|
||||
<QTime>
|
||||
<QTimer>
|
||||
|
||||
@@ -12,7 +12,6 @@ endfunction()
|
||||
|
||||
copy_framework(QtConcurrent)
|
||||
copy_framework(QtCore)
|
||||
copy_framework(QtCore5Compat)
|
||||
copy_framework(QtDBus)
|
||||
copy_framework(QtGui)
|
||||
copy_framework(QtMultimedia)
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
<distributionFile>
|
||||
<origin>../../dist/bin/Qt6Core.dll</origin>
|
||||
</distributionFile>
|
||||
<distributionFile>
|
||||
<origin>../../dist/bin/Qt6Core5Compat.dll</origin>
|
||||
</distributionFile>
|
||||
<distributionFile>
|
||||
<origin>../../dist/bin/Qt6DBus.dll</origin>
|
||||
</distributionFile>
|
||||
@@ -75,9 +72,6 @@
|
||||
<distributionFile>
|
||||
<origin>../../dist/lib/libQt6Core.so.6</origin>
|
||||
</distributionFile>
|
||||
<distributionFile>
|
||||
<origin>../../dist/lib/libQt6Core5Compat.so.6</origin>
|
||||
</distributionFile>
|
||||
<distributionFile>
|
||||
<origin>../../dist/lib/libQt6DBus.so.6</origin>
|
||||
</distributionFile>
|
||||
@@ -128,9 +122,6 @@
|
||||
<distributionDirectory>
|
||||
<origin>../../dist/lib/QtCore.framework</origin>
|
||||
</distributionDirectory>
|
||||
<distributionDirectory>
|
||||
<origin>../../dist/lib/QtCore5Compat.framework</origin>
|
||||
</distributionDirectory>
|
||||
<distributionDirectory>
|
||||
<origin>../../dist/lib/QtDBus.framework</origin>
|
||||
</distributionDirectory>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <QElapsedTimer>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionMatch>
|
||||
#include <QString>
|
||||
@@ -155,8 +154,7 @@ namespace swift::sample
|
||||
std::generate_n(std::back_inserter(strList3), 100000, generator);
|
||||
std::generate_n(std::back_inserter(strList4), 100000, generator);
|
||||
QRegularExpression newRegex("^.*aaa.*$", QRegularExpression::CaseInsensitiveOption);
|
||||
QRegExp fullRegex(".*aaa.*", Qt::CaseInsensitive);
|
||||
QRegExp wildcardRegex("*aaa*", Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
QRegularExpression fullRegex(".*aaa.*", QRegularExpression::CaseInsensitiveOption);
|
||||
QString containsStr("aaa");
|
||||
number = 0;
|
||||
timer.start();
|
||||
@@ -170,20 +168,12 @@ namespace swift::sample
|
||||
timer.start();
|
||||
for (const auto &str : std::as_const(strList2))
|
||||
{
|
||||
if (fullRegex.exactMatch(str)) number++;
|
||||
if (fullRegex.match(str).hasMatch()) number++;
|
||||
}
|
||||
ms = timer.elapsed();
|
||||
out << "full regex matched " << number << " of" << strList2.size() << " strings in " << ms << "ms" << Qt::endl;
|
||||
number = 0;
|
||||
timer.start();
|
||||
for (const auto &str : std::as_const(strList3))
|
||||
{
|
||||
if (wildcardRegex.exactMatch(str)) number++;
|
||||
}
|
||||
ms = timer.elapsed();
|
||||
out << "wildcard matched " << number << " of " << strList3.size() << " strings in " << ms << "ms" << Qt::endl;
|
||||
number = 0;
|
||||
timer.start();
|
||||
for (const auto &str : std::as_const(strList4))
|
||||
{
|
||||
if (str.contains(containsStr)) number++;
|
||||
@@ -441,7 +431,7 @@ namespace swift::sample
|
||||
auto lines = splitLinesRefs(bigString);
|
||||
Q_UNUSED(lines);
|
||||
}
|
||||
out << "Split 100,000 line string into list of lines: (QList<QStringRef>) " << timer.elapsed() << "ms"
|
||||
out << "Split 100,000 line string into list of lines: (QList<QStringView>) " << timer.elapsed() << "ms"
|
||||
<< Qt::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -141,8 +141,8 @@ namespace swift::core::fsd
|
||||
"Can't change server details while still connected");
|
||||
|
||||
const QString codecName(server.getFsdSetup().getTextCodec());
|
||||
QTextCodec *textCodec = QTextCodec::codecForName(codecName.toLocal8Bit());
|
||||
if (!textCodec) { textCodec = QTextCodec::codecForName("utf-8"); }
|
||||
auto codec = QStringDecoder::encodingForName(codecName);
|
||||
if (!codec.has_value()) { codec = QStringConverter::Utf8; }
|
||||
const int protocolRev = (server.getServerType() == CServer::FSDServerVatsim) ?
|
||||
PROTOCOL_REVISION_VATSIM_VELOCITY :
|
||||
PROTOCOL_REVISION_CLASSIC;
|
||||
@@ -150,7 +150,8 @@ namespace swift::core::fsd
|
||||
QWriteLocker l(&m_lockUserClientBuffered);
|
||||
m_server = server;
|
||||
m_protocolRevision = protocolRev;
|
||||
m_fsdTextCodec = textCodec;
|
||||
m_encoder = QStringEncoder(codec.value_or(QStringConverter::Utf8));
|
||||
m_decoder = QStringDecoder(codec.value_or(QStringConverter::Utf8));
|
||||
}
|
||||
|
||||
void CFSDClient::setCallsign(const CCallsign &callsign)
|
||||
@@ -781,7 +782,7 @@ namespace swift::core::fsd
|
||||
void CFSDClient::sendMessageString(const QString &message)
|
||||
{
|
||||
if (message.isEmpty()) { return; }
|
||||
const QByteArray bufferEncoded = m_fsdTextCodec->fromUnicode(message);
|
||||
const QByteArray bufferEncoded = m_encoder(message);
|
||||
if (m_printToConsole) { qDebug() << "FSD Sent=>" << bufferEncoded; }
|
||||
if (!m_unitTestMode) { m_socket->write(bufferEncoded); }
|
||||
|
||||
@@ -2199,7 +2200,7 @@ namespace swift::core::fsd
|
||||
{
|
||||
const QByteArray dataEncoded = m_socket->readLine();
|
||||
if (dataEncoded.isEmpty()) { continue; }
|
||||
const QString data = m_fsdTextCodec->toUnicode(dataEncoded);
|
||||
const QString data = m_decoder(dataEncoded);
|
||||
this->parseMessage(data);
|
||||
lines++;
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include <QReadWriteLock>
|
||||
#include <QString>
|
||||
#include <QTcpSocket>
|
||||
#include <QTextCodec>
|
||||
#include <QTimer>
|
||||
#include <QtGlobal>
|
||||
|
||||
@@ -651,7 +650,8 @@ namespace swift::core::fsd
|
||||
// User data
|
||||
swift::misc::network::CServer m_server;
|
||||
swift::misc::network::CLoginMode m_loginMode;
|
||||
QTextCodec *m_fsdTextCodec = nullptr;
|
||||
QStringEncoder m_encoder;
|
||||
QStringDecoder m_decoder;
|
||||
SimType m_simType = SimType::Unknown;
|
||||
PilotRating m_pilotRating = PilotRating::Unknown;
|
||||
AtcRating m_atcRating = AtcRating::Unknown;
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace swift::gui::editors
|
||||
ui->setupUi(this);
|
||||
this->resetToDefaultValues();
|
||||
ui->cb_Override->setChecked(true);
|
||||
ui->le_TextCodec->setCompleter(new QCompleter(textCodecNames(true, true), this));
|
||||
ui->le_TextCodec->setCompleter(new QCompleter(QStringDecoder::availableCodecs(), this));
|
||||
connect(ui->cb_Override, &QCheckBox::toggled, this, &CFsdSetupForm::enabledToggled, Qt::QueuedConnection);
|
||||
connect(ui->pb_SetDefaults, &QPushButton::clicked, this, &CFsdSetupForm::resetToDefaultValues);
|
||||
}
|
||||
|
||||
@@ -698,7 +698,6 @@ target_link_libraries(misc
|
||||
Qt::Network
|
||||
Qt::Multimedia
|
||||
nlohmann_json::nlohmann_json
|
||||
Qt::Core5Compat # for QStringRef
|
||||
PRIVATE
|
||||
Qt::Xml
|
||||
SimpleCrypt
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QStringRef>
|
||||
#include <QStringView>
|
||||
#include <QTextStream>
|
||||
#include <QtGlobal>
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace swift::misc::network
|
||||
{
|
||||
msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"No codec"));
|
||||
}
|
||||
if (!textCodecNames(true, true).contains(this->getTextCodec()))
|
||||
if (!QStringDecoder::availableCodecs().contains(this->getTextCodec()))
|
||||
{
|
||||
msgs.push_back(CStatusMessage(CStatusMessage::SeverityError, u"Unrecognized codec name"));
|
||||
}
|
||||
|
||||
@@ -657,13 +657,13 @@ namespace swift::misc::simulation::fscommon
|
||||
// manually parsing because QSettings did not work properly
|
||||
const QString fileContent = CFileUtils::readFileToString(configFile);
|
||||
if (fileContent.isEmpty()) { continue; }
|
||||
const QList<QStringRef> lines = splitLinesRefs(fileContent);
|
||||
const QList<QStringView> lines = splitLinesRefs(fileContent);
|
||||
static const QString p("Path=");
|
||||
for (const QStringRef &line : lines)
|
||||
for (const QStringView &line : lines)
|
||||
{
|
||||
const int i = line.lastIndexOf(p, -1, Qt::CaseInsensitive);
|
||||
if (i < 0 || line.endsWith('=')) { continue; }
|
||||
const QStringRef path = line.mid(i + p.length());
|
||||
const QStringView path = line.mid(i + p.length());
|
||||
const QDir dir(QDir::fromNativeSeparators(
|
||||
pathPrefix.isEmpty() ? path.toString() :
|
||||
CFileUtils::appendFilePathsAndFixUnc(pathPrefix, path.toString())));
|
||||
@@ -785,20 +785,20 @@ namespace swift::misc::simulation::fscommon
|
||||
{
|
||||
const QString fileContent = CFileUtils::readFileToString(fsxFile);
|
||||
if (fileContent.isEmpty()) { return QSet<QString>(); }
|
||||
const QList<QStringRef> lines = splitLinesRefs(fileContent);
|
||||
const QList<QStringView> lines = splitLinesRefs(fileContent);
|
||||
static const QString p("SimObjectPaths.");
|
||||
|
||||
const QFileInfo fsxFileInfo(fsxFile);
|
||||
const QString relPath = fsxFileInfo.absolutePath();
|
||||
|
||||
QSet<QString> paths;
|
||||
for (const QStringRef &line : lines)
|
||||
for (const QStringView &line : lines)
|
||||
{
|
||||
const int i1 = line.lastIndexOf(p, -1, Qt::CaseInsensitive);
|
||||
if (i1 < 0) { continue; }
|
||||
const int i2 = line.lastIndexOf('=');
|
||||
if (i2 < 0 || i1 >= i2 || line.endsWith('=')) { continue; }
|
||||
const QStringRef path = line.mid(i2 + 1);
|
||||
const QStringView path = line.mid(i2 + 1);
|
||||
QString soPath = QDir::fromNativeSeparators(path.toString());
|
||||
if (logConfigPathReading())
|
||||
{
|
||||
@@ -857,20 +857,20 @@ namespace swift::misc::simulation::fscommon
|
||||
{
|
||||
const QString fileContent = CFileUtils::readFileToString(msfsFile);
|
||||
if (fileContent.isEmpty()) { return QSet<QString>(); }
|
||||
const QList<QStringRef> lines = splitLinesRefs(fileContent);
|
||||
const QList<QStringView> lines = splitLinesRefs(fileContent);
|
||||
static const QString p("SimObjectPaths.");
|
||||
|
||||
const QFileInfo fsxFileInfo(msfsFile);
|
||||
const QString relPath = fsxFileInfo.absolutePath();
|
||||
|
||||
QSet<QString> paths;
|
||||
for (const QStringRef &line : lines)
|
||||
for (const QStringView &line : lines)
|
||||
{
|
||||
const int i1 = line.lastIndexOf(p, -1, Qt::CaseInsensitive);
|
||||
if (i1 < 0) { continue; }
|
||||
const int i2 = line.lastIndexOf('=');
|
||||
if (i2 < 0 || i1 >= i2 || line.endsWith('=')) { continue; }
|
||||
const QStringRef path = line.mid(i2 + 1);
|
||||
const QStringView path = line.mid(i2 + 1);
|
||||
QString soPath = QDir::fromNativeSeparators(path.toString());
|
||||
if (logConfigPathReading())
|
||||
{
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <QChar>
|
||||
#include <QRegularExpression>
|
||||
#include <QStringBuilder>
|
||||
#include <QTextCodec>
|
||||
|
||||
namespace swift::misc
|
||||
{
|
||||
@@ -17,7 +16,7 @@ namespace swift::misc
|
||||
return removeChars(s, [](QChar c) { return c == u' ' || c == u':' || c == u'_' || c == u'-' || c == u'.'; });
|
||||
}
|
||||
|
||||
QList<QStringRef> splitLinesRefs(const QString &s)
|
||||
QList<QStringView> splitLinesRefs(const QString &s)
|
||||
{
|
||||
return splitStringRefs(s, [](QChar c) { return c == '\n' || c == '\r'; });
|
||||
}
|
||||
@@ -210,44 +209,6 @@ namespace swift::misc
|
||||
return s.contains(' ') ? s.left(s.indexOf(' ')) : s;
|
||||
}
|
||||
|
||||
QStringList simpleTextCodecNamesImpl()
|
||||
{
|
||||
QStringList codecs;
|
||||
for (const QByteArray &ba : QTextCodec::availableCodecs())
|
||||
{
|
||||
const QString c(QString::fromLocal8Bit(ba));
|
||||
codecs << c;
|
||||
}
|
||||
return codecs;
|
||||
}
|
||||
|
||||
QStringList mibTextCodecNamesImpl()
|
||||
{
|
||||
QStringList codecs;
|
||||
for (int mib : QTextCodec::availableMibs())
|
||||
{
|
||||
const QByteArray ba(QTextCodec::codecForMib(mib)->name());
|
||||
const QString c(QString::fromLocal8Bit(ba));
|
||||
codecs << c;
|
||||
}
|
||||
return codecs;
|
||||
}
|
||||
|
||||
QStringList textCodecNames(bool simpleNames, bool mibNames)
|
||||
{
|
||||
static const QStringList simple(simpleTextCodecNamesImpl());
|
||||
static const QStringList mib(mibTextCodecNamesImpl());
|
||||
if (simpleNames && mibNames)
|
||||
{
|
||||
QStringList s(simple);
|
||||
s.append(mib);
|
||||
return s;
|
||||
}
|
||||
if (simpleNames) { return simple; }
|
||||
if (mibNames) { return mib; }
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
// http://www.codegur.online/14009522/how-to-remove-accents-diacritic-marks-from-a-string-in-qt
|
||||
// https://stackoverflow.com/questions/14009522/how-to-remove-accents-diacritic-marks-from-a-string-in-qt
|
||||
// https://german.stackexchange.com/questions/4992/conversion-table-for-diacritics-e-g-%C3%BC-%E2%86%92-ue
|
||||
@@ -458,11 +419,11 @@ namespace swift::misc
|
||||
QMap<QString, QString> parseIniValues(const QString &data)
|
||||
{
|
||||
QMap<QString, QString> map;
|
||||
QList<QStringRef> lines = splitLinesRefs(data);
|
||||
for (const QStringRef &l : lines)
|
||||
QList<QStringView> lines = splitLinesRefs(data);
|
||||
for (const QStringView &l : lines)
|
||||
{
|
||||
if (l.isEmpty()) { continue; }
|
||||
const int i = l.indexOf("=");
|
||||
const int i = l.indexOf('=');
|
||||
if (i < 0 || i >= l.length() + 1) { continue; }
|
||||
|
||||
const QString key = l.left(i).trimmed().toString();
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <QMapIterator>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
#include <QStringRef>
|
||||
#include <QStringView>
|
||||
#include <QtGlobal>
|
||||
|
||||
@@ -89,9 +88,9 @@ namespace swift::misc
|
||||
//! Split a string into multiple strings, using a predicate function to identify the split points.
|
||||
//! \warning The returned refs are only valid during the lifetime of the original string.
|
||||
template <class F>
|
||||
QList<QStringRef> splitStringRefs(const QString &s, F predicate)
|
||||
QList<QStringView> splitStringRefs(const QString &s, F predicate)
|
||||
{
|
||||
QList<QStringRef> result;
|
||||
QList<QStringView> result;
|
||||
auto notPredicate = [=](auto c) { return !predicate(c); };
|
||||
auto begin = s.begin();
|
||||
while (true)
|
||||
@@ -99,14 +98,14 @@ namespace swift::misc
|
||||
begin = std::find_if(begin, s.end(), notPredicate);
|
||||
if (begin == s.end()) { return result; }
|
||||
auto end = std::find_if(begin, s.end(), predicate);
|
||||
result.push_back(QStringRef(&s, std::distance(s.begin(), begin), std::distance(begin, end)));
|
||||
result.push_back(QStringView(s).slice(std::distance(s.begin(), begin), std::distance(begin, end)));
|
||||
begin = end;
|
||||
}
|
||||
}
|
||||
|
||||
//! Split a string into multiple lines. Blank lines are skipped.
|
||||
//! \warning The returned refs are only valid during the lifetime of the original string.
|
||||
SWIFT_MISC_EXPORT QList<QStringRef> splitLinesRefs(const QString &s);
|
||||
SWIFT_MISC_EXPORT QList<QStringView> splitLinesRefs(const QString &s);
|
||||
|
||||
//! It would be risky to call splitStringRefs with an rvalue, so forbid it.
|
||||
template <class F>
|
||||
@@ -119,7 +118,7 @@ namespace swift::misc
|
||||
template <class F>
|
||||
QStringList splitString(const QString &s, F predicate)
|
||||
{
|
||||
return makeRange(splitStringRefs(s, predicate)).transform([](QStringRef sr) { return sr.toString(); });
|
||||
return makeRange(splitStringRefs(s, predicate)).transform([](QStringView sv) { return sv.toString(); });
|
||||
}
|
||||
|
||||
//! Split a string into multiple lines. Blank lines are skipped.
|
||||
@@ -256,9 +255,6 @@ namespace swift::misc
|
||||
//! Strip a designator from a combined string
|
||||
SWIFT_MISC_EXPORT QString stripDesignatorFromCompleterString(const QString &candidate);
|
||||
|
||||
//! Strip a designator from a combined string
|
||||
SWIFT_MISC_EXPORT QStringList textCodecNames(bool simpleNames, bool mibNames);
|
||||
|
||||
//! Remove accents / diacritic marks from a string
|
||||
SWIFT_MISC_EXPORT QString simplifyAccents(const QString &candidate);
|
||||
|
||||
@@ -333,11 +329,6 @@ namespace swift::misc
|
||||
static QString toQString(const QString &s) { return s; }
|
||||
};
|
||||
template <>
|
||||
struct TString<QStringRef>
|
||||
{
|
||||
static QString toQString(const QStringRef &sr) { return sr.toString(); }
|
||||
};
|
||||
template <>
|
||||
struct TString<QStringView>
|
||||
{
|
||||
static QString toQString(QStringView sv) { return sv.toString(); }
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#include <QTest>
|
||||
#include <QTextCodec>
|
||||
#include <QTime>
|
||||
|
||||
#include "test.h"
|
||||
@@ -130,18 +129,21 @@ namespace MiscTest
|
||||
|
||||
void CTestStringUtils::testCodecs()
|
||||
{
|
||||
QTextCodec *latin1 = QTextCodec::codecForName("latin1");
|
||||
QTextCodec *cp1251 = QTextCodec::codecForName("windows-1251");
|
||||
QTextCodec *utf8 = QTextCodec::codecForName("UTF-8");
|
||||
const QStringConverter::Encoding latin1_enc = QStringDecoder::encodingForName("latin1").value();
|
||||
const QStringConverter::Encoding utf8_enc = QStringDecoder::encodingForName("UTF-8").value();
|
||||
|
||||
QStringDecoder latin1_decoder = QStringDecoder(latin1_enc);
|
||||
QStringEncoder latin1_encoder = QStringEncoder(latin1_enc);
|
||||
QStringDecoder utf8_decoder = QStringDecoder(utf8_enc);
|
||||
QStringEncoder utf8_encoder = QStringEncoder(utf8_enc);
|
||||
|
||||
const QString testEnglish = QStringLiteral(u"test");
|
||||
const QString testRussian = QStringLiteral(u"тест");
|
||||
bool okEn1 = latin1->toUnicode(latin1->fromUnicode(testEnglish)) == testEnglish;
|
||||
bool okEn2 = utf8->toUnicode(utf8->fromUnicode(testEnglish)) == testEnglish;
|
||||
bool okRu1 = cp1251->toUnicode(cp1251->fromUnicode(testRussian)) == testRussian;
|
||||
bool okRu2 = utf8->toUnicode(utf8->fromUnicode(testRussian)) == testRussian;
|
||||
bool okEn1 = latin1_decoder(latin1_encoder(testEnglish)) == testEnglish;
|
||||
bool okEn2 = utf8_decoder(utf8_encoder(testEnglish)) == testEnglish;
|
||||
bool okRu2 = utf8_decoder(utf8_encoder(testRussian)) == testRussian;
|
||||
QVERIFY2(okEn1, "English \"test\" equal after round-trip with latin1");
|
||||
QVERIFY2(okEn2, "English \"test\" equal after round-trip with utf8");
|
||||
QVERIFY2(okRu1, "Russian \"test\" equal after round-trip with cp1251");
|
||||
QVERIFY2(okRu2, "Russian \"test\" equal after round-trip with utf8");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user