txt support
This commit is contained in:
11 files changed
+781
-14
No files matched your search
@@ -16,6 +16,7 @@ private slots:
|
||||
void testDecodeWindows1251();
|
||||
void testDecodeWithHint();
|
||||
void testDecodeWithExplicitEncoding();
|
||||
void testAutoDetectWindows1251();
|
||||
};
|
||||
|
||||
void TextEncodingTest::testEmpty()
|
||||
@@ -108,5 +109,17 @@ void TextEncodingTest::testDecodeWithExplicitEncoding()
|
||||
QVERIFY(invalid.isEmpty());
|
||||
}
|
||||
|
||||
void TextEncodingTest::testAutoDetectWindows1251()
|
||||
{
|
||||
// Russian text in windows-1251 without BOM or headers: "Версия для программистов"
|
||||
const QByteArray win1251("\xC2\xE5\xF0\xF1\xE8\xFF\x20\xE4\xEB\xFF\x20\xEF\xF0\xEE\xE3\xF0\xE0\xEC\xEC\xE8\xF1\xF2\xEE\xE2");
|
||||
const QString enc = TextEncoding::detectEncoding(win1251);
|
||||
QCOMPARE(enc.toLower(), QStringLiteral("windows-1251"));
|
||||
|
||||
const QString result = TextEncoding::decode(win1251);
|
||||
QCOMPARE(result, QString::fromUtf8("Версия для программистов"));
|
||||
QVERIFY(!result.contains(QChar::ReplacementCharacter));
|
||||
}
|
||||
|
||||
QTEST_MAIN(TextEncodingTest)
|
||||
#include "TextEncodingTest.moc"
|
||||
Reference in new issue
Block a user