1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
43 #include <QtTest/QtTest>
45 #include <qtextcodec.h>
47 #include <qtextdocument.h>
50 #include <QThreadPool>
52 class tst_QTextCodec : public QObject
59 void toUnicode_data();
61 void codecForName_data();
63 void fromUnicode_data();
65 void toUnicode_codecForHtml();
66 void toUnicode_incremental();
67 void codecForLocale();
69 void asciiToIscii() const;
70 void flagCodepointFFFF() const;
71 void flagF7808080() const;
72 void flagEFBFBF() const;
73 void decode0D() const;
74 void aliasForUTF16() const;
75 void mibForTSCII() const;
77 void utf8Codec_data();
83 void utfHeaders_data();
88 void codecForUtfText_data();
89 void codecForUtfText();
91 #if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
96 void checkAliases_data();
99 void moreToFromUnicode_data();
100 void moreToFromUnicode();
105 void tst_QTextCodec::toUnicode_data()
107 QTest::addColumn<QString>("fileName");
108 QTest::addColumn<QString>("codecName");
110 QTest::newRow( "korean-eucKR" ) << QFINDTESTDATA("korean.txt") << "eucKR";
111 QTest::newRow( "UTF-8" ) << QFINDTESTDATA("utf8.txt") << "UTF-8";
114 void tst_QTextCodec::toUnicode()
116 QFETCH( QString, fileName );
117 QFETCH( QString, codecName );
119 QFile file( fileName );
121 if ( file.open( QIODevice::ReadOnly ) ) {
122 QByteArray ba = file.readAll();
123 QVERIFY(!ba.isEmpty());
124 QTextCodec *c = QTextCodec::codecForName( codecName.toLatin1() );
126 QString uniString = c->toUnicode( ba );
127 if (codecName == QLatin1String("UTF-8")) {
128 QCOMPARE(uniString, QString::fromUtf8(ba));
129 QCOMPARE(ba, uniString.toUtf8());
131 QVERIFY(!uniString.isEmpty());
132 QCOMPARE( ba, c->fromUnicode( uniString ) );
134 if (codecName == QLatin1String("eucKR")) {
136 QVERIFY(c->toUnicode(&ch, 1).isEmpty());
137 QVERIFY(c->toUnicode(&ch, 1).isNull());
140 QFAIL(qPrintable("File could not be opened: " + file.errorString()));
144 void tst_QTextCodec::codecForName_data()
146 QTest::addColumn<QString>("hint");
147 QTest::addColumn<QString>("actualCodecName");
149 QTest::newRow("data1") << "iso88591" << "ISO-8859-1";
150 QTest::newRow("data2") << "iso88592" << "ISO-8859-2";
151 QTest::newRow("data3") << " IsO(8)8/5*9-2 " << "ISO-8859-2";
152 QTest::newRow("data4") << " IsO(8)8/5*2-9 " << "";
153 QTest::newRow("data5") << "latin2" << "ISO-8859-2";
156 void tst_QTextCodec::codecForName()
158 QFETCH(QString, hint);
159 QFETCH(QString, actualCodecName);
161 QTextCodec *codec = QTextCodec::codecForName(hint.toLatin1());
162 if (actualCodecName.isEmpty()) {
166 QCOMPARE(QString(codec->name()), actualCodecName);
170 void tst_QTextCodec::fromUnicode_data()
172 QTest::addColumn<QString>("codecName");
173 QTest::addColumn<bool>("eightBit");
175 QTest::newRow("data1") << "ISO-8859-1" << true;
176 QTest::newRow("data2") << "ISO-8859-2" << true;
177 QTest::newRow("data3") << "ISO-8859-3" << true;
178 QTest::newRow("data4") << "ISO-8859-4" << true;
179 QTest::newRow("data5") << "ISO-8859-5" << true;
180 QTest::newRow("data6") << "ISO-8859-6" << true;
181 QTest::newRow("data7") << "ISO-8859-7" << true;
182 QTest::newRow("data8") << "ISO-8859-8" << true;
183 QTest::newRow("data9") << "ISO-8859-9" << true;
184 QTest::newRow("data10") << "ISO-8859-10" << true;
185 QTest::newRow("data13") << "ISO-8859-13" << true;
186 QTest::newRow("data14") << "ISO-8859-14" << true;
187 QTest::newRow("data15") << "ISO-8859-15" << true;
188 QTest::newRow("data16") << "ISO-8859-16" << true;
190 QTest::newRow("data18") << "IBM850" << true;
191 QTest::newRow("data19") << "IBM874" << true;
192 QTest::newRow("data20") << "IBM866" << true;
194 QTest::newRow("data21") << "windows-1250" << true;
195 QTest::newRow("data22") << "windows-1251" << true;
196 QTest::newRow("data23") << "windows-1252" << true;
197 QTest::newRow("data24") << "windows-1253" << true;
198 QTest::newRow("data25") << "windows-1254" << true;
199 QTest::newRow("data26") << "windows-1255" << true;
200 QTest::newRow("data27") << "windows-1256" << true;
201 QTest::newRow("data28") << "windows-1257" << true;
202 QTest::newRow("data28") << "windows-1258" << true;
204 QTest::newRow("data29") << "Apple Roman" << true;
205 QTest::newRow("data29") << "WINSAMI2" << true;
206 QTest::newRow("data30") << "TIS-620" << true;
207 QTest::newRow("data31") << "roman8" << true;
209 QTest::newRow("data32") << "SJIS" << false;
210 QTest::newRow("data33") << "EUC-KR" << false;
212 // all codecs from documentation
213 QTest::newRow("doc2") << "Big5" << false;
214 QTest::newRow("doc3") << "Big5-HKSCS" << false;
215 QTest::newRow("doc4") << "CP949" << false;
216 QTest::newRow("doc5") << "EUC-JP" << false;
217 QTest::newRow("doc6") << "EUC-KR" << false;
218 //QTest::newRow("doc7") << "GB18030-0" << false; // only GB18030 works
219 QTest::newRow("doc7-bis") << "GB18030" << false;
220 QTest::newRow("doc8") << "IBM 850" << false;
221 QTest::newRow("doc9") << "IBM 866" << false;
222 QTest::newRow("doc10") << "IBM 874" << false;
223 QTest::newRow("doc11") << "ISO 2022-JP" << false;
224 //ISO 8859-1 to 10 and ISO 8859-13 to 16 tested previously
225 // Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml tested in Iscii test
226 //QTest::newRow("doc12") << "JIS X 0201" << false; //actually not there
227 //QTest::newRow("doc13") << "JIS X 0208" << false; // actually not there
228 QTest::newRow("doc14") << "KOI8-R" << false;
229 QTest::newRow("doc15") << "KOI8-U" << false;
230 //QTest::newRow("doc16") << "MuleLao-1" << false; //only on x11
231 QTest::newRow("doc17") << "ROMAN8" << false;
232 QTest::newRow("doc18") << "Shift-JIS" << false;
233 QTest::newRow("doc19") << "TIS-620" << false;
234 QTest::newRow("doc20") << "TSCII" << false;
235 QTest::newRow("doc21") << "UTF-8" << false;
236 QTest::newRow("doc22") << "UTF-16" << false;
237 QTest::newRow("doc23") << "UTF-16BE" << false;
238 QTest::newRow("doc24") << "UTF-16LE" << false;
239 QTest::newRow("doc25") << "UTF-32" << false;
240 QTest::newRow("doc26") << "UTF-32BE" << false;
241 QTest::newRow("doc27") << "UTF-32LE" << false;
242 //Windows-1250 to 1258 tested previously
243 QTest::newRow("doc3") << "WINSAMI2" << false;
246 void tst_QTextCodec::fromUnicode()
248 QFETCH(QString, codecName);
249 QFETCH(bool, eightBit);
251 QTextCodec *codec = QTextCodec::codecForName(codecName.toLatin1());
254 // Check if the reverse lookup is what we expect
257 for (int i = 0; i < 128; ++i)
259 QString s = codec->toUnicode(chars, 128);
260 QByteArray c = codec->fromUnicode(s);
261 QCOMPARE(c.size(), 128);
263 int numberOfQuestionMarks = 0;
264 for (int i = 0; i < 128; ++i) {
266 ++numberOfQuestionMarks;
268 QCOMPARE(c.at(i), char(i + 128));
270 QVERIFY(numberOfQuestionMarks != 128);
274 If the encoding is a superset of ASCII, test that the byte
275 array is correct (no off by one, no trailing '\0').
277 QByteArray result = codec->fromUnicode(QString("abc"));
278 if (result.startsWith("a")) {
279 QCOMPARE(result.size(), 3);
280 QCOMPARE(result, QByteArray("abc"));
286 void tst_QTextCodec::toUnicode_codecForHtml()
288 QFile file(QFINDTESTDATA("QT4-crashtest.txt"));
289 QVERIFY(file.open(QFile::ReadOnly));
291 QByteArray data = file.readAll();
292 QTextCodec *codec = Qt::codecForHtml(data);
293 codec->toUnicode(data); // this line crashes
297 void tst_QTextCodec::toUnicode_incremental()
309 QString expected = QString::fromUtf8(ba);
312 QTextDecoder *utf8Decoder = QTextCodec::codecForMib(106)->makeDecoder();
315 for (int i = 0; i < ba.size(); ++i)
316 utf8Decoder->toUnicode(&actual, ba.constData() + i, 1);
318 QCOMPARE(actual, expected);
324 void tst_QTextCodec::codecForLocale()
326 QTextCodec *codec = QTextCodec::codecForLocale();
329 // The rest of this test is for Unix only
330 #if defined(Q_OS_UNIX)
331 // get a time string that is locale-encoded
332 QByteArray originalLocaleEncodedTimeString;
333 originalLocaleEncodedTimeString.resize(1024);
336 int r = strftime(originalLocaleEncodedTimeString.data(),
337 originalLocaleEncodedTimeString.size(),
341 originalLocaleEncodedTimeString.resize(r);
343 QString unicodeTimeString = codec->toUnicode(originalLocaleEncodedTimeString);
344 QByteArray localeEncodedTimeString = codec->fromUnicode(unicodeTimeString);
345 QCOMPARE(localeEncodedTimeString, originalLocaleEncodedTimeString);
347 // find a codec that is not the codecForLocale()
348 QTextCodec *codec2 = 0;
349 foreach (int mib, QTextCodec::availableMibs()) {
350 if (mib != codec->mibEnum()) {
351 codec2 = QTextCodec::codecForMib(mib);
357 // Only run the rest of the test if we could find a codec that is not
358 // already the codecForLocale().
360 // set it, codecForLocale() should return it now
361 QTextCodec::setCodecForLocale(codec2);
362 QCOMPARE(QTextCodec::codecForLocale(), codec2);
364 // reset back to the default
365 QTextCodec::setCodecForLocale(0);
366 QCOMPARE(QTextCodec::codecForLocale(), codec);
371 void tst_QTextCodec::asciiToIscii() const
373 /* Add all low, 7-bit ASCII characters. */
375 const int len = 0xA0 - 1;
378 for(int i = 0; i < len; ++i)
379 ascii[i] = QChar(i + 1);
381 static const char *const isciiCodecs[] =
393 const int isciiCodecsLen = sizeof(isciiCodecs) / sizeof(const char *);
395 for(int i = 0; i < isciiCodecsLen; ++i) {
396 /* For each codec. */
398 const QTextCodec *const textCodec = QTextCodec::codecForName(isciiCodecs[i]);
401 for(int i2 = 0; i2 < len; ++i2) {
402 /* For each character in ascii. */
403 const QChar c(ascii[i2]);
404 QVERIFY2(textCodec->canEncode(c), qPrintable(QString::fromLatin1("Failed to encode %1 with encoding %2")
405 .arg(QString::number(c.unicode()), QString::fromLatin1(textCodec->name().constData()))));
408 QVERIFY2(textCodec->canEncode(ascii), qPrintable(QString::fromLatin1("Failed for full string with encoding %1")
409 .arg(QString::fromLatin1(textCodec->name().constData()))));
413 void tst_QTextCodec::flagCodepointFFFF() const
415 // This is an invalid Unicode codepoint.
416 const QChar ch(0xFFFF);
419 QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
422 const QByteArray asDecoded(codec->fromUnicode(input));
423 QCOMPARE(asDecoded, QByteArray("?"));
425 QByteArray ffff("\357\277\277");
426 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
427 QVERIFY(codec->toUnicode(ffff.constData(), ffff.length(), &state) == QChar(0));
428 QVERIFY(codec->toUnicode(ffff) == QChar(0xfffd));
431 void tst_QTextCodec::flagF7808080() const
433 /* This test case stems from test not-wf-sa-170, tests/qxmlstream/XML-Test-Suite/xmlconf/xmltest/not-wf/sa/166.xml,
434 * whose description reads:
436 * "Four byte UTF-8 encodings can encode UCS-4 characters
437 * which are beyond the range of legal XML characters
438 * (and can't be expressed in Unicode surrogate pairs).
439 * This document holds such a character."
441 * In binary, this is:
442 * 11110111100000001000000010000000
444 * 11110www10xxxxxx10yyyyyy10zzzzzz
446 * With multibyte logic removed it is the codepoint 0x1C0000.
450 input[0] = char(0xF7);
451 input[1] = char(0x80);
452 input[2] = char(0x80);
453 input[3] = char(0x80);
455 QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
458 //QVERIFY(!codec->canEncode(QChar(0x1C0000)));
460 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
461 QVERIFY(codec->toUnicode(input.constData(), input.length(), &state) == QChar(0));
464 void tst_QTextCodec::flagEFBFBF() const
466 QByteArray invalidInput;
467 invalidInput.resize(3);
468 invalidInput[0] = char(0xEF);
469 invalidInput[1] = char(0xBF);
470 invalidInput[2] = char(0xBF);
472 const QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
476 //QVERIFY(!codec->canEncode(QChar(0xFFFF)));
477 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
478 QVERIFY(codec->toUnicode(invalidInput.constData(), invalidInput.length(), &state) == QChar(0));
480 QByteArray start("<?pi ");
481 start.append(invalidInput);
485 /* When 0xEFBFBF is preceded by what seems to be an arbitrary character,
486 * QTextCodec fails to flag it. */
488 QByteArray start("B");
489 start.append(invalidInput);
491 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
492 QVERIFY(codec->toUnicode(start.constData(), start.length(), &state) == QString::fromLatin1("B\0", 2));
496 void tst_QTextCodec::decode0D() const
504 QCOMPARE(QString::fromUtf8(input.constData()).toUtf8(), input);
507 void tst_QTextCodec::aliasForUTF16() const
509 QVERIFY(QTextCodec::codecForName("UTF-16")->aliases().isEmpty());
512 void tst_QTextCodec::mibForTSCII() const
514 QTextCodec *codec = QTextCodec::codecForName("TSCII");
516 QCOMPARE(codec->mibEnum(), 2107);
519 static QString fromInvalidUtf8Sequence(const QByteArray &ba)
521 return QString().fill(QChar::ReplacementCharacter, ba.size());
524 // copied from tst_QString::fromUtf8_data()
525 void tst_QTextCodec::utf8Codec_data()
527 QTest::addColumn<QByteArray>("utf8");
528 QTest::addColumn<QString>("res");
529 QTest::addColumn<int>("len");
532 QTest::newRow("str0") << QByteArray("abcdefgh") << QString("abcdefgh") << -1;
533 QTest::newRow("str0-len") << QByteArray("abcdefgh") << QString("abc") << 3;
534 QTest::newRow("str1") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") << QString("\366\344\374\326\304\334\370\346\345\330\306\305") << -1;
535 QTest::newRow("str1-len") << QByteArray("\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205") << QString("\366\344\374\326\304") << 10;
537 str += QChar(0x05e9);
538 str += QChar(0x05d3);
539 str += QChar(0x05d2);
540 QTest::newRow("str2") << QByteArray("\327\251\327\223\327\222") << str << -1;
543 QTest::newRow("str2-len") << QByteArray("\327\251\327\223\327\222") << str << 2;
547 QTest::newRow("str3") << QByteArray("\342\202\254 some text") << str << -1;
551 QTest::newRow("str3-len") << QByteArray("\342\202\254 some text") << str << 9;
554 str += QChar::ReplacementCharacter;
556 str += QChar::ReplacementCharacter;
557 str += QChar::ReplacementCharacter;
558 str += QChar::ReplacementCharacter;
559 str += QChar::ReplacementCharacter;
561 str += QChar::ReplacementCharacter;
562 QTest::newRow("invalid utf8") << QByteArray("hello\344h\344\344\366\344a\304") << str << -1;
563 QTest::newRow("invalid utf8-len") << QByteArray("hello\344h\344\344\366\344a\304") << QString("hello") << 5;
566 str += QChar::ReplacementCharacter;
567 str += QChar::ReplacementCharacter;
569 str += QChar::ReplacementCharacter;
571 str += QChar::ReplacementCharacter;
574 QTest::newRow("task28417") << QByteArray("Prohl\355\276e\350 plugin\371 Netscape") << str << -1;
575 QTest::newRow("task28417-len") << QByteArray("Prohl\355\276e\350 plugin\371 Netscape") << QString("") << 0;
577 QTest::newRow("null-1") << QByteArray() << QString() << -1;
578 QTest::newRow("null0") << QByteArray() << QString() << 0;
579 // QTest::newRow("null5") << QByteArray() << QString() << 5;
580 QTest::newRow("empty-1") << QByteArray("\0abcd", 5) << QString() << -1;
581 QTest::newRow("empty0") << QByteArray() << QString() << 0;
582 QTest::newRow("empty5") << QByteArray("\0abcd", 5) << QString::fromAscii("\0abcd", 5) << 5;
583 QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << QString::fromAscii("ab") << -1;
584 QTest::newRow("other5") << QByteArray("ab\0cd", 5) << QString::fromAscii("ab\0cd", 5) << 5;
586 str = "Old Italic: ";
587 str += QChar(0xd800);
588 str += QChar(0xdf00);
589 str += QChar(0xd800);
590 str += QChar(0xdf01);
591 str += QChar(0xd800);
592 str += QChar(0xdf02);
593 str += QChar(0xd800);
594 str += QChar(0xdf03);
595 str += QChar(0xd800);
596 str += QChar(0xdf04);
597 QTest::newRow("surrogate") << QByteArray("Old Italic: \360\220\214\200\360\220\214\201\360\220\214\202\360\220\214\203\360\220\214\204") << str << -1;
599 QTest::newRow("surrogate-len") << QByteArray("Old Italic: \360\220\214\200\360\220\214\201\360\220\214\202\360\220\214\203\360\220\214\204") << str.left(16) << 20;
601 // from http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html
606 str = QChar(QChar::Null);
607 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.1") << utf8 << str << 1;
614 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.2") << utf8 << str << -1;
622 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.3") << utf8 << str << -1;
631 str += QChar(0xd800);
632 str += QChar(0xdc00);
633 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.4") << utf8 << str << -1;
635 // 2.1.5 U+00200000 (not a valid Unicode character)
642 str = fromInvalidUtf8Sequence(utf8);
643 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.5") << utf8 << str << -1;
645 // 2.1.6 U+04000000 (not a valid Unicode character)
653 str = fromInvalidUtf8Sequence(utf8);
654 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.6") << utf8 << str << -1;
660 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.1") << utf8 << str << -1;
667 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.2") << utf8 << str << -1;
675 str += QChar::ReplacementCharacter;
676 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.3") << utf8 << str << -1;
685 str += QChar(QChar::ReplacementCharacter);
686 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.4") << utf8 << str << -1;
688 // 2.2.5 U+03FFFFFF (not a valid Unicode character)
695 str = fromInvalidUtf8Sequence(utf8);
696 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.5") << utf8 << str << -1;
706 str = fromInvalidUtf8Sequence(utf8);
707 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.6") << utf8 << str << -1;
715 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.1") << utf8 << str << -1;
723 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.2") << utf8 << str << -1;
730 str = QChar(QChar::ReplacementCharacter);
731 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.3") << utf8 << str << -1;
740 str += QChar(0xdbff);
741 str += QChar(0xdffd);
742 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.4") << utf8 << str << -1;
751 str += QChar(QChar::ReplacementCharacter);
752 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.5") << utf8 << str << -1;
757 str = fromInvalidUtf8Sequence(utf8);
758 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.1") << utf8 << str << -1;
763 str = fromInvalidUtf8Sequence(utf8);
764 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.2") << utf8 << str << -1;
770 str = fromInvalidUtf8Sequence(utf8);
771 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.3") << utf8 << str << -1;
778 str = fromInvalidUtf8Sequence(utf8);
779 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.4") << utf8 << str << -1;
787 str = fromInvalidUtf8Sequence(utf8);
788 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.5") << utf8 << str << -1;
797 str = fromInvalidUtf8Sequence(utf8);
798 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.6") << utf8 << str << -1;
808 str = fromInvalidUtf8Sequence(utf8);
809 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.7") << utf8 << str << -1;
820 str = fromInvalidUtf8Sequence(utf8);
821 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.8") << utf8 << str << -1;
825 for (uint i = 0x80; i<= 0xbf; ++i)
827 str = fromInvalidUtf8Sequence(utf8);
828 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.9") << utf8 << str << -1;
833 for (uint i = 0xc8; i <= 0xdf; ++i) {
837 str += QChar::ReplacementCharacter;
838 str += QChar(0x0020);
840 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.1") << utf8 << str << -1;
845 for (uint i = 0xe0; i <= 0xef; ++i) {
849 str += QChar::ReplacementCharacter;
850 str += QChar(0x0020);
852 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.2") << utf8 << str << -1;
857 for (uint i = 0xf0; i <= 0xf7; ++i) {
861 str += QChar::ReplacementCharacter;
862 str += QChar(0x0020);
864 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.3") << utf8 << str << -1;
869 for (uint i = 0xf8; i <= 0xfb; ++i) {
873 str += QChar::ReplacementCharacter;
874 str += QChar(0x0020);
876 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.4") << utf8 << str << -1;
881 for (uint i = 0xfc; i <= 0xfd; ++i) {
885 str += QChar::ReplacementCharacter;
886 str += QChar(0x0020);
888 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.5") << utf8 << str << -1;
893 str = fromInvalidUtf8Sequence(utf8);
894 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.1") << utf8 << str << -1;
897 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.1-1") << utf8 << str << -1;
903 str = fromInvalidUtf8Sequence(utf8);
904 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2") << utf8 << str << -1;
907 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-1") << utf8 << str << -1;
911 str = fromInvalidUtf8Sequence(utf8);
912 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-2") << utf8 << str << -1;
915 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-3") << utf8 << str << -1;
922 str = fromInvalidUtf8Sequence(utf8);
923 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3") << utf8 << str << -1;
926 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-1") << utf8 << str << -1;
930 str = fromInvalidUtf8Sequence(utf8);
931 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-2") << utf8 << str << -1;
934 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-3") << utf8 << str << -1;
939 str = fromInvalidUtf8Sequence(utf8);
940 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-4") << utf8 << str << -1;
943 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-5") << utf8 << str << -1;
951 str = fromInvalidUtf8Sequence(utf8);
952 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4") << utf8 << str << -1;
955 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-1") << utf8 << str << -1;
961 str = fromInvalidUtf8Sequence(utf8);
962 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-2") << utf8 << str << -1;
965 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-3") << utf8 << str << -1;
970 str = fromInvalidUtf8Sequence(utf8);
971 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-4") << utf8 << str << -1;
974 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-5") << utf8 << str << -1;
978 str = fromInvalidUtf8Sequence(utf8);
979 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-6") << utf8 << str << -1;
982 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-7") << utf8 << str << -1;
991 str = fromInvalidUtf8Sequence(utf8);
992 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5") << utf8 << str << -1;
995 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-1") << utf8 << str << -1;
1002 str = fromInvalidUtf8Sequence(utf8);
1003 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-2") << utf8 << str << -1;
1006 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-3") << utf8 << str << -1;
1012 str = fromInvalidUtf8Sequence(utf8);
1013 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-4") << utf8 << str << -1;
1016 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-5") << utf8 << str << -1;
1021 str = fromInvalidUtf8Sequence(utf8);
1022 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-6") << utf8 << str << -1;
1025 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-7") << utf8 << str << -1;
1029 str = fromInvalidUtf8Sequence(utf8);
1030 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-8") << utf8 << str << -1;
1033 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-9") << utf8 << str << -1;
1038 str = fromInvalidUtf8Sequence(utf8);
1039 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.6") << utf8 << str << -1;
1042 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.6-1") << utf8 << str << -1;
1048 str = fromInvalidUtf8Sequence(utf8);
1049 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7") << utf8 << str << -1;
1052 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-1") << utf8 << str << -1;
1056 str = fromInvalidUtf8Sequence(utf8);
1057 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-2") << utf8 << str << -1;
1060 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-3") << utf8 << str << -1;
1067 str = fromInvalidUtf8Sequence(utf8);
1068 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8") << utf8 << str << -1;
1071 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-1") << utf8 << str << -1;
1076 str = fromInvalidUtf8Sequence(utf8);
1077 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-2") << utf8 << str << -1;
1080 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-3") << utf8 << str << -1;
1084 str = fromInvalidUtf8Sequence(utf8);
1085 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-4") << utf8 << str << -1;
1088 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-5") << utf8 << str << -1;
1096 str = fromInvalidUtf8Sequence(utf8);
1097 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9") << utf8 << str << -1;
1100 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-1") << utf8 << str << -1;
1106 str = fromInvalidUtf8Sequence(utf8);
1107 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-2") << utf8 << str << -1;
1110 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-3") << utf8 << str << -1;
1115 str = fromInvalidUtf8Sequence(utf8);
1116 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-4") << utf8 << str << -1;
1119 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-5") << utf8 << str << -1;
1123 str = fromInvalidUtf8Sequence(utf8);
1124 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-6") << utf8 << str << -1;
1127 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-7") << utf8 << str << -1;
1136 str = fromInvalidUtf8Sequence(utf8);
1137 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10") << utf8 << str << -1;
1140 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-1") << utf8 << str << -1;
1147 str = fromInvalidUtf8Sequence(utf8);
1148 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-2") << utf8 << str << -1;
1151 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-3") << utf8 << str << -1;
1157 str = fromInvalidUtf8Sequence(utf8);
1158 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-4") << utf8 << str << -1;
1161 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-5") << utf8 << str << -1;
1166 str = fromInvalidUtf8Sequence(utf8);
1167 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-6") << utf8 << str << -1;
1170 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-7") << utf8 << str << -1;
1174 str = fromInvalidUtf8Sequence(utf8);
1175 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-8") << utf8 << str << -1;
1178 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-9") << utf8 << str << -1;
1212 str = fromInvalidUtf8Sequence(utf8);
1213 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.4") << utf8 << str << -1;
1218 str = fromInvalidUtf8Sequence(utf8);
1219 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.5.1") << utf8 << str << -1;
1224 str = fromInvalidUtf8Sequence(utf8);
1225 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.5.1") << utf8 << str << -1;
1232 str = fromInvalidUtf8Sequence(utf8);
1233 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.5.1") << utf8 << str << -1;
1239 str = QChar(QChar::ReplacementCharacter);
1240 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.1") << utf8 << str << -1;
1247 str = QChar(QChar::ReplacementCharacter);
1248 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.2") << utf8 << str << -1;
1256 str = QChar(QChar::ReplacementCharacter);
1257 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.3") << utf8 << str << -1;
1266 str = fromInvalidUtf8Sequence(utf8);
1267 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.4") << utf8 << str << -1;
1277 str = fromInvalidUtf8Sequence(utf8);
1278 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.5") << utf8 << str << -1;
1284 str = QChar(QChar::ReplacementCharacter);
1285 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.1") << utf8 << str << -1;
1292 str = QChar(QChar::ReplacementCharacter);
1293 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.2") << utf8 << str << -1;
1301 str = QChar(QChar::ReplacementCharacter);
1302 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.3") << utf8 << str << -1;
1311 str = fromInvalidUtf8Sequence(utf8);
1312 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.4") << utf8 << str << -1;
1322 str = fromInvalidUtf8Sequence(utf8);
1323 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.5") << utf8 << str << -1;
1329 str = QChar(QChar::ReplacementCharacter);
1330 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.1") << utf8 << str << -1;
1337 str = QChar(QChar::ReplacementCharacter);
1338 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.2") << utf8 << str << -1;
1346 str = QChar(QChar::ReplacementCharacter);
1347 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.3") << utf8 << str << -1;
1356 str = fromInvalidUtf8Sequence(utf8);
1357 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.4") << utf8 << str << -1;
1367 str = fromInvalidUtf8Sequence(utf8);
1368 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.5") << utf8 << str << -1;
1375 str = QChar(QChar::ReplacementCharacter);
1376 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.1") << utf8 << str << -1;
1383 str = QChar(QChar::ReplacementCharacter);
1384 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.2") << utf8 << str << -1;
1391 str = QChar(QChar::ReplacementCharacter);
1392 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.3") << utf8 << str << -1;
1399 str = QChar(QChar::ReplacementCharacter);
1400 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.4") << utf8 << str << -1;
1407 str = QChar(QChar::ReplacementCharacter);
1408 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.5") << utf8 << str << -1;
1415 str = QChar(QChar::ReplacementCharacter);
1416 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.6") << utf8 << str << -1;
1423 str = QChar(QChar::ReplacementCharacter);
1424 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.7") << utf8 << str << -1;
1435 str += QChar(QChar::ReplacementCharacter);
1436 str += QChar(QChar::ReplacementCharacter);
1437 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.1") << utf8 << str << -1;
1448 str += QChar(QChar::ReplacementCharacter);
1449 str += QChar(QChar::ReplacementCharacter);
1450 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.2") << utf8 << str << -1;
1461 str += QChar(QChar::ReplacementCharacter);
1462 str += QChar(QChar::ReplacementCharacter);
1463 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.3") << utf8 << str << -1;
1474 str += QChar(QChar::ReplacementCharacter);
1475 str += QChar(QChar::ReplacementCharacter);
1476 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.4") << utf8 << str << -1;
1487 str += QChar(QChar::ReplacementCharacter);
1488 str += QChar(QChar::ReplacementCharacter);
1489 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.5") << utf8 << str << -1;
1500 str += QChar(QChar::ReplacementCharacter);
1501 str += QChar(QChar::ReplacementCharacter);
1502 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.6") << utf8 << str << -1;
1513 str += QChar(QChar::ReplacementCharacter);
1514 str += QChar(QChar::ReplacementCharacter);
1515 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.7") << utf8 << str << -1;
1526 str += QChar(QChar::ReplacementCharacter);
1527 str += QChar(QChar::ReplacementCharacter);
1528 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.8") << utf8 << str << -1;
1535 str = QChar(QChar::ReplacementCharacter);
1536 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.3.1") << utf8 << str << -1;
1543 str = QChar(QChar::ReplacementCharacter);
1544 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.3.2") << utf8 << str << -1;
1547 void tst_QTextCodec::utf8Codec()
1549 QTextCodec *codec = QTextCodec::codecForMib(106); // UTF-8
1550 QVERIFY(codec != 0);
1552 QFETCH(QByteArray, utf8);
1553 QFETCH(QString, res);
1556 QString str = codec->toUnicode(utf8.isNull() ? 0 : utf8.constData(),
1557 len < 0 ? qstrlen(utf8.constData()) : len);
1560 str = QString::fromUtf8(utf8.isNull() ? 0 : utf8.constData(), len);
1564 void tst_QTextCodec::utf8bom_data()
1566 QTest::addColumn<QByteArray>("data");
1567 QTest::addColumn<QString>("result");
1569 QTest::newRow("nobom")
1570 << QByteArray("\302\240", 2)
1574 static const ushort data[] = { 0x201d };
1575 QTest::newRow("nobom 2")
1576 << QByteArray("\342\200\235", 3)
1577 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1581 static const ushort data[] = { 0xf000 };
1582 QTest::newRow("bom1")
1583 << QByteArray("\357\200\200", 3)
1584 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1588 static const ushort data[] = { 0xfec0 };
1589 QTest::newRow("bom2")
1590 << QByteArray("\357\273\200", 3)
1591 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1595 QTest::newRow("normal-bom")
1596 << QByteArray("\357\273\277a", 4)
1601 static const ushort data[] = { 0x61, 0xfeff, 0x62 };
1602 QTest::newRow("middle-bom")
1603 << QByteArray("a\357\273\277b", 5)
1604 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1608 void tst_QTextCodec::utf8bom()
1610 QFETCH(QByteArray, data);
1611 QFETCH(QString, result);
1613 QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
1616 QCOMPARE(codec->toUnicode(data.constData(), data.length(), 0), result);
1618 QTextCodec::ConverterState state;
1619 QCOMPARE(codec->toUnicode(data.constData(), data.length(), &state), result);
1622 void tst_QTextCodec::utfHeaders_data()
1624 QTest::addColumn<QByteArray>("codecName");
1625 QTest::addColumn<int>("flags");
1626 QTest::addColumn<QByteArray>("encoded");
1627 QTest::addColumn<QString>("unicode");
1628 QTest::addColumn<bool>("toUnicode");
1630 QTest::newRow("utf8 bom")
1631 << QByteArray("UTF-8")
1633 << QByteArray("\xef\xbb\xbfhello")
1634 << QString::fromLatin1("hello")
1636 QTest::newRow("utf8 nobom")
1637 << QByteArray("UTF-8")
1639 << QByteArray("hello")
1640 << QString::fromLatin1("hello")
1642 QTest::newRow("utf8 bom ignore header")
1643 << QByteArray("UTF-8")
1644 << (int)QTextCodec::IgnoreHeader
1645 << QByteArray("\xef\xbb\xbfhello")
1646 << (QString(QChar(0xfeff)) + QString::fromLatin1("hello"))
1648 QTest::newRow("utf8 nobom ignore header")
1649 << QByteArray("UTF-8")
1650 << (int)QTextCodec::IgnoreHeader
1651 << QByteArray("hello")
1652 << QString::fromLatin1("hello")
1655 QTest::newRow("utf16 bom be")
1656 << QByteArray("UTF-16")
1658 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1659 << QString::fromLatin1("hel")
1661 QTest::newRow("utf16 bom le")
1662 << QByteArray("UTF-16")
1664 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1665 << QString::fromLatin1("hel")
1667 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
1668 QTest::newRow("utf16 nobom")
1669 << QByteArray("UTF-16")
1671 << QByteArray("\0h\0e\0l", 6)
1672 << QString::fromLatin1("hel")
1674 QTest::newRow("utf16 bom be ignore header")
1675 << QByteArray("UTF-16")
1676 << (int)QTextCodec::IgnoreHeader
1677 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1678 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1681 QTest::newRow("utf16 nobom")
1682 << QByteArray("UTF-16")
1684 << QByteArray("h\0e\0l\0", 6)
1685 << QString::fromLatin1("hel")
1687 QTest::newRow("utf16 bom le ignore header")
1688 << QByteArray("UTF-16")
1689 << (int)QTextCodec::IgnoreHeader
1690 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1691 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1695 QTest::newRow("utf16-be bom be")
1696 << QByteArray("UTF-16BE")
1698 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1699 << QString::fromLatin1("hel")
1701 QTest::newRow("utf16-be nobom")
1702 << QByteArray("UTF-16BE")
1704 << QByteArray("\0h\0e\0l", 6)
1705 << QString::fromLatin1("hel")
1707 QTest::newRow("utf16-be bom be ignore header")
1708 << QByteArray("UTF-16BE")
1709 << (int)QTextCodec::IgnoreHeader
1710 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1711 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1714 QTest::newRow("utf16-le bom le")
1715 << QByteArray("UTF-16LE")
1717 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1718 << QString::fromLatin1("hel")
1720 QTest::newRow("utf16-le nobom")
1721 << QByteArray("UTF-16LE")
1723 << QByteArray("h\0e\0l\0", 6)
1724 << QString::fromLatin1("hel")
1726 QTest::newRow("utf16-le bom le ignore header")
1727 << QByteArray("UTF-16LE")
1728 << (int)QTextCodec::IgnoreHeader
1729 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1730 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1734 QTest::newRow("utf32 bom be")
1735 << QByteArray("UTF-32")
1737 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1738 << QString::fromLatin1("hel")
1740 QTest::newRow("utf32 bom le")
1741 << QByteArray("UTF-32")
1743 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1744 << QString::fromLatin1("hel")
1746 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
1747 QTest::newRow("utf32 nobom")
1748 << QByteArray("UTF-32")
1750 << QByteArray("\0\0\0h\0\0\0e\0\0\0l", 12)
1751 << QString::fromLatin1("hel")
1753 QTest::newRow("utf32 bom be ignore header")
1754 << QByteArray("UTF-32")
1755 << (int)QTextCodec::IgnoreHeader
1756 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1757 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1760 QTest::newRow("utf32 nobom")
1761 << QByteArray("UTF-32")
1763 << QByteArray("h\0\0\0e\0\0\0l\0\0\0", 12)
1764 << QString::fromLatin1("hel")
1766 QTest::newRow("utf32 bom le ignore header")
1767 << QByteArray("UTF-32")
1768 << (int)QTextCodec::IgnoreHeader
1769 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1770 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1775 QTest::newRow("utf32-be bom be")
1776 << QByteArray("UTF-32BE")
1778 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1779 << QString::fromLatin1("hel")
1781 QTest::newRow("utf32-be nobom")
1782 << QByteArray("UTF-32BE")
1784 << QByteArray("\0\0\0h\0\0\0e\0\0\0l", 12)
1785 << QString::fromLatin1("hel")
1787 QTest::newRow("utf32-be bom be ignore header")
1788 << QByteArray("UTF-32BE")
1789 << (int)QTextCodec::IgnoreHeader
1790 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1791 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1795 QTest::newRow("utf32-le bom le")
1796 << QByteArray("UTF-32LE")
1798 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1799 << QString::fromLatin1("hel")
1801 QTest::newRow("utf32-le nobom")
1802 << QByteArray("UTF-32LE")
1804 << QByteArray("h\0\0\0e\0\0\0l\0\0\0", 12)
1805 << QString::fromLatin1("hel")
1807 QTest::newRow("utf32-le bom le ignore header")
1808 << QByteArray("UTF-32LE")
1809 << (int)QTextCodec::IgnoreHeader
1810 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1811 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1815 void tst_QTextCodec::utfHeaders()
1817 QFETCH(QByteArray, codecName);
1818 QTextCodec *codec = QTextCodec::codecForName(codecName);
1819 QVERIFY(codec != 0);
1822 QTextCodec::ConversionFlags cFlags = QTextCodec::ConversionFlags(flags);
1823 QTextCodec::ConverterState state(cFlags);
1825 QFETCH(QByteArray, encoded);
1826 QFETCH(QString, unicode);
1828 QFETCH(bool, toUnicode);
1830 QLatin1String ignoreReverseTestOn = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? QLatin1String(" le") : QLatin1String(" be");
1831 QString rowName(QTest::currentDataTag());
1834 QString result = codec->toUnicode(encoded.constData(), encoded.length(), &state);
1835 QCOMPARE(result.length(), unicode.length());
1836 QCOMPARE(result, unicode);
1838 if (!rowName.endsWith("nobom") && !rowName.contains(ignoreReverseTestOn)) {
1839 QTextCodec::ConverterState state2(cFlags);
1840 QByteArray reencoded = codec->fromUnicode(unicode.unicode(), unicode.length(), &state2);
1841 QCOMPARE(reencoded, encoded);
1844 QByteArray result = codec->fromUnicode(unicode.unicode(), unicode.length(), &state);
1845 QCOMPARE(result, encoded);
1849 void tst_QTextCodec::codecForHtml()
1851 QByteArray html("<html><head></head><body>blah</body></html>");
1853 QCOMPARE(QTextCodec::codecForHtml(html)->mibEnum(), 4); // latin 1
1855 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 106); // UTF-8
1857 html = "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-15\" /></head></html>";
1858 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 111); // latin 15
1860 html = "<html><head><meta content=\"text/html; charset=ISO-8859-15\" http-equiv=\"content-type\" /></head></html>";
1861 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 111); // latin 15
1863 html = "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=invalid-foo\" /></head></html>";
1864 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 106); // UTF-8
1865 QCOMPARE(QTextCodec::codecForHtml(html)->mibEnum(), 4); // latin 1
1868 void tst_QTextCodec::codecForUtfText_data()
1870 QTest::addColumn<QByteArray>("encoded");
1871 QTest::addColumn<bool>("detected");
1872 QTest::addColumn<int>("mib");
1875 QTest::newRow("utf8 bom")
1876 << QByteArray("\xef\xbb\xbfhello")
1879 QTest::newRow("utf8 nobom")
1880 << QByteArray("hello")
1884 QTest::newRow("utf16 bom be")
1885 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1888 QTest::newRow("utf16 bom le")
1889 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1892 QTest::newRow("utf16 nobom")
1893 << QByteArray("\0h\0e\0l", 6)
1897 QTest::newRow("utf32 bom be")
1898 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1901 QTest::newRow("utf32 bom le")
1902 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1905 QTest::newRow("utf32 nobom")
1906 << QByteArray("\0\0\0h\0\0\0e\0\0\0l", 12)
1911 void tst_QTextCodec::codecForUtfText()
1913 QFETCH(QByteArray, encoded);
1914 QFETCH(bool, detected);
1917 QTextCodec *codec = QTextCodec::codecForUtfText(encoded, 0);
1919 QCOMPARE(codec->mibEnum(), mib);
1921 QVERIFY(codec == 0);
1924 #if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
1925 void tst_QTextCodec::toLocal8Bit()
1928 process.start("echo/echo");
1929 QString string(QChar(0x410));
1930 process.write((const char*)string.utf16(), string.length()*2);
1932 process.closeWriteChannel();
1933 process.waitForFinished();
1934 QCOMPARE(process.exitStatus(), QProcess::NormalExit);
1935 QCOMPARE(process.exitCode(), 0);
1939 class LoadAndConvert: public QRunnable
1942 LoadAndConvert(const QByteArray &source, QByteArray *destination)
1943 : codecName(source), target(destination)
1945 QByteArray codecName;
1949 QTextCodec *c = QTextCodec::codecForName(codecName);
1951 qWarning() << "WARNING" << codecName << "not found?";
1954 QString str = QString::fromLatin1(codecName);
1955 QByteArray b = c->fromUnicode(str);
1957 *target = codecName;
1961 class LoadAndConvertMIB: public QRunnable
1964 LoadAndConvertMIB(int mib, int *target)
1965 : mib(mib), target(target)
1971 QTextCodec *c = QTextCodec::codecForMib(mib);
1973 qWarning() << "WARNING" << mib << "not found?";
1976 QString str = QString::number(mib);
1977 QByteArray b = c->fromUnicode(str);
1984 void tst_QTextCodec::threadSafety()
1986 QList<QByteArray> codecList = QTextCodec::availableCodecs();
1987 QList<int> mibList = QTextCodec::availableMibs();
1988 QThreadPool::globalInstance()->setMaxThreadCount(12);
1990 QVector<QByteArray> res;
1991 res.resize(codecList.size());
1992 for (int i = 0; i < codecList.size(); ++i) {
1993 QThreadPool::globalInstance()->start(new LoadAndConvert(codecList.at(i), &res[i]));
1997 res2.resize(mibList.size());
1998 for (int i = 0; i < mibList.size(); ++i) {
1999 QThreadPool::globalInstance()->start(new LoadAndConvertMIB(mibList.at(i), &res2[i]));
2002 // wait for all threads to finish working
2003 QThreadPool::globalInstance()->waitForDone();
2005 QCOMPARE(res.toList(), codecList);
2006 QCOMPARE(res2.toList(), mibList);
2009 void tst_QTextCodec::invalidNames()
2011 QVERIFY(!QTextCodec::codecForName(""));
2012 QVERIFY(!QTextCodec::codecForName(QByteArray()));
2013 QVERIFY(!QTextCodec::codecForName("-"));
2014 QVERIFY(!QTextCodec::codecForName("\1a\2b\3a\4d\5c\6s\7a\xffr\xec_\x9c_"));
2015 QVERIFY(!QTextCodec::codecForName("\n"));
2016 QVERIFY(!QTextCodec::codecForName("don't exist"));
2017 QByteArray huge = "azertyuiop^$qsdfghjklm<wxcvbn,;:=1234567890�_";
2018 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2019 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2020 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2021 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2022 QVERIFY(!QTextCodec::codecForName(huge));
2025 void tst_QTextCodec::checkAliases_data()
2027 QTest::addColumn<QByteArray>("codecName");
2028 QList<QByteArray> codecList = QTextCodec::availableCodecs();
2029 foreach (const QByteArray &a, codecList) {
2030 QTest::newRow( a.constData() ) << a;
2034 void tst_QTextCodec::checkAliases()
2036 QFETCH( QByteArray, codecName );
2037 QTextCodec *c = QTextCodec::codecForName(codecName);
2039 QCOMPARE(QTextCodec::codecForName(codecName), c);
2040 QCOMPARE(QTextCodec::codecForName(c->name()), c);
2042 foreach(const QByteArray &a, c->aliases()) {
2043 QCOMPARE(QTextCodec::codecForName(a), c);
2048 void tst_QTextCodec::moreToFromUnicode_data() {
2049 QTest::addColumn<QByteArray>("codecName");
2050 QTest::addColumn<QByteArray>("testData");
2052 QTest::newRow("russian") << QByteArray("ISO-8859-5")
2053 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF\x00");
2055 QTest::newRow("arabic") << QByteArray("ISO-8859-6")
2056 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA4\xAC\xAD\xBB\xBF\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2");
2058 QTest::newRow("greek") << QByteArray("ISO-8859-7")
2059 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA6\xA7\xA8\xA9\xAB\xAC\xAD\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE");
2061 QTest::newRow("turkish") << QByteArray("ISO-8859-9")
2062 << QByteArray("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2064 QTest::newRow("latin1") << QByteArray("ISO-8859-1")
2065 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2067 QByteArray sms7bit_ba;
2068 for (int i=1; i <= 0x7f; ++i) {
2070 sms7bit_ba.append(i);
2074 QTest::newRow("latin2") << QByteArray("ISO-8859-2")
2075 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2077 QTest::newRow("latin3") << QByteArray("ISO-8859-3")
2078 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBF\xC0\xC1\xC2\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2080 QTest::newRow("latin4") << QByteArray("ISO-8859-4")
2081 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2083 QTest::newRow("russian 2") << QByteArray("ISO-8859-5")
2084 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2086 QTest::newRow("arabic 2") << QByteArray("ISO-8859-6")
2087 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA4\xAC\xAD\xBB\xBF\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2");
2089 QTest::newRow("greek 2") << QByteArray("ISO-8859-7")
2090 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA6\xA7\xA8\xA9\xAB\xAC\xAD\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE");
2092 QTest::newRow("latin5") << QByteArray("ISO-8859-9")
2093 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2095 QTest::newRow("latin6") << QByteArray("ISO-8859-10")
2096 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2099 QByteArray iso8859_11_ba;
2100 for (int x=0x20; x<=0x7f; ++x) {
2101 iso8859_11_ba.append(x);
2103 for (int x=0xa0; x<0xff; ++x) {
2104 if ((x>=0xdb && x<0xdf) || x>0xfb){
2107 iso8859_11_ba.append(x);
2109 QTest::newRow("latin-thai") << QByteArray("ISO-8859-11") << iso8859_11_ba;
2112 QTest::newRow("latin7") << QByteArray("ISO-8859-13")
2113 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2115 QTest::newRow("celtic") << QByteArray("ISO-8859-14")
2116 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2118 QTest::newRow("latin9") << QByteArray("ISO-8859-15")
2119 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2121 QTest::newRow("latin10") << QByteArray("ISO-8859-16")
2122 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2124 QTest::newRow("cp850") << QByteArray("CP850")
2125 << QByteArray("\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff");
2127 QTest::newRow("cp874") << QByteArray("CP874")
2128 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x85\x91\x92\x93\x94\x95\x96\x97\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB");
2130 QTest::newRow("cp1250") << QByteArray("CP1250")
2131 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x84\x85\x86\x87\x89\x8A\x8B\x8C\x8D\x8E\x8F\x91\x92\x93\x94\x95\x96\x97\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2133 QTest::newRow("cp1251") << QByteArray("CP1251")
2134 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2136 QTest::newRow("cp1252") << QByteArray("CP1252")
2137 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8E\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2139 QTest::newRow("cp1253") << QByteArray("CP1253")
2140 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x83\x84\x85\x86\x87\x89\x8B\x91\x92\x93\x94\x95\x96\x97\x99\x9B\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE");
2142 QTest::newRow("cp1254") << QByteArray("CP1254")
2143 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2145 QTest::newRow("cp1255") << QByteArray("CP1255")
2146 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x83\x84\x85\x86\x87\x88\x89,x8B\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9B\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFD\xFE");
2148 QTest::newRow("cp1256") << QByteArray("CP1256")
2149 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2151 QTest::newRow("cp1257") << QByteArray("CP1257")
2152 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x84\x85\x86\x87\x89\x8B\x8D\x8E\x8F\x91\x92\x93\x94\x95\x96\x97\x99\x9B\x9D\x9E\xA0\xA2\xA3\xA4\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2154 QTest::newRow("cp1258") << QByteArray("CP1258")
2155 << QByteArray("\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A\x7B\x7C\x7D\x7E\x7F\x80\x82\x83\x84\x85\x86\x87\x88\x89\x8B\x8C\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9B\x9C\x9F\xA0\xA1\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xDB\xDC\xDD\xDE\xDF\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF");
2157 QByteArray koi8_r_ba;
2158 for (int x=0x20; x<=0xff; ++x) {
2159 if (x!=0x9A && x!=0xbf) {
2160 koi8_r_ba.append(x);
2163 QTest::newRow("KOI8-R") << QByteArray("KOI8-R") << koi8_r_ba;
2165 QByteArray koi8_u_ba;
2166 for (int x=0x20; x<=0xff; ++x) {
2167 koi8_u_ba.append(x);
2169 QTest::newRow("KOI8-U") << QByteArray("KOI8-U") << koi8_u_ba;
2173 for (unsigned char u=0xa1; u<=0xf9; u++) {
2177 for (unsigned char v=0x40; v<=0x7e; v++) {
2183 case 0xa3: v_up=0xbf; break;
2184 case 0xc7: v_up=0xfc; break;
2185 case 0xf9: v_up=0xd5; break;
2189 for (unsigned char v=0xa1; v<=v_up; v++) {
2190 if (u==0xa2 && (v==0xcc || v==0xce)) {
2198 QTest::newRow("BIG5") << QByteArray("BIG5") << big5_ba;
2200 QByteArray gb2312_ba;
2201 for (unsigned char u=0xa1; u<=0xf7; u++) {
2202 for (unsigned char v=0xa1; v<=0xfe; v++) {
2203 gb2312_ba.append(u);
2204 gb2312_ba.append(v);
2208 QTest::newRow("GB2312") << QByteArray("GB2312") << gb2312_ba;
2211 void tst_QTextCodec::moreToFromUnicode()
2213 QFETCH( QByteArray, codecName );
2214 QFETCH( QByteArray, testData );
2216 QTextCodec *c = QTextCodec::codecForName( codecName.data() );
2219 QString uStr = c->toUnicode(testData);
2220 QByteArray cStr = c->fromUnicode(uStr);
2221 QCOMPARE(testData, cStr);
2224 void tst_QTextCodec::shiftJis()
2226 QByteArray backslashTilde("\\~");
2227 QTextCodec* codec = QTextCodec::codecForName("shift_jis");
2228 QString string = codec->toUnicode(backslashTilde);
2229 QCOMPARE(string.length(), 2);
2230 QCOMPARE(string.at(0), QChar(QLatin1Char('\\')));
2231 QCOMPARE(string.at(1), QChar(QLatin1Char('~')));
2233 QByteArray encoded = codec->fromUnicode(string);
2234 QCOMPARE(encoded, backslashTilde);
2237 struct DontCrashAtExit {
2238 ~DontCrashAtExit() {
2239 QTextCodec *c = QTextCodec::codecForName("utf8");
2241 c->toUnicode("azerty");
2247 QTEST_MAIN(tst_QTextCodec)
2248 #include "tst_qtextcodec.moc"