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("ISO-8859-1") << "ISO-8859-1" << true;
176 QTest::newRow("ISO-8859-2") << "ISO-8859-2" << true;
177 QTest::newRow("ISO-8859-3") << "ISO-8859-3" << true;
178 QTest::newRow("ISO-8859-4") << "ISO-8859-4" << true;
179 QTest::newRow("ISO-8859-5") << "ISO-8859-5" << true;
180 QTest::newRow("ISO-8859-6") << "ISO-8859-6" << true;
181 QTest::newRow("ISO-8859-7") << "ISO-8859-7" << true;
182 QTest::newRow("ISO-8859-8") << "ISO-8859-8" << true;
183 QTest::newRow("ISO-8859-9") << "ISO-8859-9" << true;
184 QTest::newRow("ISO-8859-10") << "ISO-8859-10" << true;
185 QTest::newRow("ISO-8859-13") << "ISO-8859-13" << true;
186 QTest::newRow("ISO-8859-14") << "ISO-8859-14" << true;
187 QTest::newRow("ISO-8859-15") << "ISO-8859-15" << true;
188 QTest::newRow("ISO-8859-16") << "ISO-8859-16" << true;
190 QTest::newRow("IBM850") << "IBM850" << true;
191 QTest::newRow("IBM874") << "IBM874" << true;
192 QTest::newRow("IBM866") << "IBM866" << true;
194 QTest::newRow("windows-1250") << "windows-1250" << true;
195 QTest::newRow("windows-1251") << "windows-1251" << true;
196 QTest::newRow("windows-1252") << "windows-1252" << true;
197 QTest::newRow("windows-1253") << "windows-1253" << true;
198 QTest::newRow("windows-1254") << "windows-1254" << true;
199 QTest::newRow("windows-1255") << "windows-1255" << true;
200 QTest::newRow("windows-1256") << "windows-1256" << true;
201 QTest::newRow("windows-1257") << "windows-1257" << true;
202 QTest::newRow("windows-1258") << "windows-1258" << true;
204 QTest::newRow("Apple Roman") << "Apple Roman" << true;
205 QTest::newRow("WINSAMI2") << "WINSAMI2" << true;
206 QTest::newRow("TIS-620") << "TIS-620" << true;
207 QTest::newRow("roman8") << "roman8" << true;
208 QTest::newRow("SJIS") << "SJIS" << false;
210 // all codecs from documentation
211 QTest::newRow("Big5") << "Big5" << false;
212 QTest::newRow("Big5-HKSCS") << "Big5-HKSCS" << false;
213 QTest::newRow("CP949") << "CP949" << false;
214 QTest::newRow("EUC-JP") << "EUC-JP" << false;
215 QTest::newRow("EUC-KR") << "EUC-KR" << false;
216 //QTest::newRow("GB18030-0") << "GB18030-0" << false; // only GB18030 works
217 QTest::newRow("GB18030") << "GB18030" << false;
218 QTest::newRow("IBM 850") << "IBM 850" << false;
219 QTest::newRow("IBM 866") << "IBM 866" << false;
220 QTest::newRow("IBM 874") << "IBM 874" << false;
221 QTest::newRow("ISO 2022-JP") << "ISO 2022-JP" << false;
222 //ISO 8859-1 to 10 and ISO 8859-13 to 16 tested previously
223 // Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml tested in Iscii test
224 //QTest::newRow("JIS X 0201") << "JIS X 0201" << false; // actually not there
225 //QTest::newRow("JIS X 0208") << "JIS X 0208" << false; // actually not there
226 QTest::newRow("KOI8-R") << "KOI8-R" << false;
227 QTest::newRow("KOI8-U") << "KOI8-U" << false;
228 //QTest::newRow("MuleLao-1") << "MuleLao-1" << false; //only on x11
229 QTest::newRow("ROMAN8") << "ROMAN8" << false;
230 QTest::newRow("Shift-JIS") << "Shift-JIS" << false;
231 QTest::newRow("TIS-620") << "TIS-620" << false;
232 QTest::newRow("TSCII") << "TSCII" << false;
233 QTest::newRow("UTF-8") << "UTF-8" << false;
234 QTest::newRow("UTF-16") << "UTF-16" << false;
235 QTest::newRow("UTF-16BE") << "UTF-16BE" << false;
236 QTest::newRow("UTF-16LE") << "UTF-16LE" << false;
237 QTest::newRow("UTF-32") << "UTF-32" << false;
238 QTest::newRow("UTF-32BE") << "UTF-32BE" << false;
239 QTest::newRow("UTF-32LE") << "UTF-32LE" << false;
240 //Windows-1250 to 1258 tested previously
243 void tst_QTextCodec::fromUnicode()
245 QFETCH(QString, codecName);
246 QFETCH(bool, eightBit);
248 QTextCodec *codec = QTextCodec::codecForName(codecName.toLatin1());
251 // Check if the reverse lookup is what we expect
254 for (int i = 0; i < 128; ++i)
256 QString s = codec->toUnicode(chars, 128);
257 QByteArray c = codec->fromUnicode(s);
258 QCOMPARE(c.size(), 128);
260 int numberOfQuestionMarks = 0;
261 for (int i = 0; i < 128; ++i) {
263 ++numberOfQuestionMarks;
265 QCOMPARE(c.at(i), char(i + 128));
267 QVERIFY(numberOfQuestionMarks != 128);
271 If the encoding is a superset of ASCII, test that the byte
272 array is correct (no off by one, no trailing '\0').
274 QByteArray result = codec->fromUnicode(QString("abc"));
275 if (result.startsWith("a")) {
276 QCOMPARE(result.size(), 3);
277 QCOMPARE(result, QByteArray("abc"));
283 void tst_QTextCodec::toUnicode_codecForHtml()
285 QFile file(QFINDTESTDATA("QT4-crashtest.txt"));
286 QVERIFY(file.open(QFile::ReadOnly));
288 QByteArray data = file.readAll();
289 QTextCodec *codec = Qt::codecForHtml(data);
290 codec->toUnicode(data); // this line crashes
294 void tst_QTextCodec::toUnicode_incremental()
306 QString expected = QString::fromUtf8(ba);
309 QTextDecoder *utf8Decoder = QTextCodec::codecForMib(106)->makeDecoder();
312 for (int i = 0; i < ba.size(); ++i)
313 utf8Decoder->toUnicode(&actual, ba.constData() + i, 1);
315 QCOMPARE(actual, expected);
321 void tst_QTextCodec::codecForLocale()
323 QTextCodec *codec = QTextCodec::codecForLocale();
326 // The rest of this test is for Unix only
327 #if defined(Q_OS_UNIX)
328 // get a time string that is locale-encoded
329 QByteArray originalLocaleEncodedTimeString;
330 originalLocaleEncodedTimeString.resize(1024);
333 int r = strftime(originalLocaleEncodedTimeString.data(),
334 originalLocaleEncodedTimeString.size(),
338 originalLocaleEncodedTimeString.resize(r);
340 QString unicodeTimeString = codec->toUnicode(originalLocaleEncodedTimeString);
341 QByteArray localeEncodedTimeString = codec->fromUnicode(unicodeTimeString);
342 QCOMPARE(localeEncodedTimeString, originalLocaleEncodedTimeString);
344 // find a codec that is not the codecForLocale()
345 QTextCodec *codec2 = 0;
346 foreach (int mib, QTextCodec::availableMibs()) {
347 if (mib != codec->mibEnum()) {
348 codec2 = QTextCodec::codecForMib(mib);
354 // Only run the rest of the test if we could find a codec that is not
355 // already the codecForLocale().
357 // set it, codecForLocale() should return it now
358 QTextCodec::setCodecForLocale(codec2);
359 QCOMPARE(QTextCodec::codecForLocale(), codec2);
361 // reset back to the default
362 QTextCodec::setCodecForLocale(0);
363 QCOMPARE(QTextCodec::codecForLocale(), codec);
368 void tst_QTextCodec::asciiToIscii() const
370 /* Add all low, 7-bit ASCII characters. */
372 const int len = 0xA0 - 1;
375 for(int i = 0; i < len; ++i)
376 ascii[i] = QChar(i + 1);
378 static const char *const isciiCodecs[] =
390 const int isciiCodecsLen = sizeof(isciiCodecs) / sizeof(const char *);
392 for(int i = 0; i < isciiCodecsLen; ++i) {
393 /* For each codec. */
395 const QTextCodec *const textCodec = QTextCodec::codecForName(isciiCodecs[i]);
398 for(int i2 = 0; i2 < len; ++i2) {
399 /* For each character in ascii. */
400 const QChar c(ascii[i2]);
401 QVERIFY2(textCodec->canEncode(c), qPrintable(QString::fromLatin1("Failed to encode %1 with encoding %2")
402 .arg(QString::number(c.unicode()), QString::fromLatin1(textCodec->name().constData()))));
405 QVERIFY2(textCodec->canEncode(ascii), qPrintable(QString::fromLatin1("Failed for full string with encoding %1")
406 .arg(QString::fromLatin1(textCodec->name().constData()))));
410 void tst_QTextCodec::flagCodepointFFFF() const
412 // This is an invalid Unicode codepoint.
413 const QChar ch(0xFFFF);
416 QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
419 const QByteArray asDecoded(codec->fromUnicode(input));
420 QCOMPARE(asDecoded, QByteArray("?"));
422 QByteArray ffff("\357\277\277");
423 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
424 QVERIFY(codec->toUnicode(ffff.constData(), ffff.length(), &state) == QChar(0));
425 QVERIFY(codec->toUnicode(ffff) == QChar(0xfffd));
428 void tst_QTextCodec::flagF7808080() const
430 /* This test case stems from test not-wf-sa-170, tests/qxmlstream/XML-Test-Suite/xmlconf/xmltest/not-wf/sa/166.xml,
431 * whose description reads:
433 * "Four byte UTF-8 encodings can encode UCS-4 characters
434 * which are beyond the range of legal XML characters
435 * (and can't be expressed in Unicode surrogate pairs).
436 * This document holds such a character."
438 * In binary, this is:
439 * 11110111100000001000000010000000
441 * 11110www10xxxxxx10yyyyyy10zzzzzz
443 * With multibyte logic removed it is the codepoint 0x1C0000.
447 input[0] = char(0xF7);
448 input[1] = char(0x80);
449 input[2] = char(0x80);
450 input[3] = char(0x80);
452 QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
455 //QVERIFY(!codec->canEncode(QChar(0x1C0000)));
457 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
458 QVERIFY(codec->toUnicode(input.constData(), input.length(), &state) == QChar(0));
461 void tst_QTextCodec::flagEFBFBF() const
463 QByteArray invalidInput;
464 invalidInput.resize(3);
465 invalidInput[0] = char(0xEF);
466 invalidInput[1] = char(0xBF);
467 invalidInput[2] = char(0xBF);
469 const QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
473 //QVERIFY(!codec->canEncode(QChar(0xFFFF)));
474 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
475 QVERIFY(codec->toUnicode(invalidInput.constData(), invalidInput.length(), &state) == QChar(0));
477 QByteArray start("<?pi ");
478 start.append(invalidInput);
482 /* When 0xEFBFBF is preceded by what seems to be an arbitrary character,
483 * QTextCodec fails to flag it. */
485 QByteArray start("B");
486 start.append(invalidInput);
488 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
489 QVERIFY(codec->toUnicode(start.constData(), start.length(), &state) == QString::fromLatin1("B\0", 2));
493 void tst_QTextCodec::decode0D() const
501 QCOMPARE(QString::fromUtf8(input.constData()).toUtf8(), input);
504 void tst_QTextCodec::aliasForUTF16() const
506 QVERIFY(QTextCodec::codecForName("UTF-16")->aliases().isEmpty());
509 void tst_QTextCodec::mibForTSCII() const
511 QTextCodec *codec = QTextCodec::codecForName("TSCII");
513 QCOMPARE(codec->mibEnum(), 2107);
516 static QString fromInvalidUtf8Sequence(const QByteArray &ba)
518 return QString().fill(QChar::ReplacementCharacter, ba.size());
521 // copied from tst_QString::fromUtf8_data()
522 void tst_QTextCodec::utf8Codec_data()
524 QTest::addColumn<QByteArray>("utf8");
525 QTest::addColumn<QString>("res");
526 QTest::addColumn<int>("len");
529 QTest::newRow("str0") << QByteArray("abcdefgh") << QString("abcdefgh") << -1;
530 QTest::newRow("str0-len") << QByteArray("abcdefgh") << QString("abc") << 3;
531 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;
532 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;
534 str += QChar(0x05e9);
535 str += QChar(0x05d3);
536 str += QChar(0x05d2);
537 QTest::newRow("str2") << QByteArray("\327\251\327\223\327\222") << str << -1;
540 QTest::newRow("str2-len") << QByteArray("\327\251\327\223\327\222") << str << 2;
544 QTest::newRow("str3") << QByteArray("\342\202\254 some text") << str << -1;
548 QTest::newRow("str3-len") << QByteArray("\342\202\254 some text") << str << 9;
551 str += QChar::ReplacementCharacter;
553 str += QChar::ReplacementCharacter;
554 str += QChar::ReplacementCharacter;
555 str += QChar::ReplacementCharacter;
556 str += QChar::ReplacementCharacter;
558 str += QChar::ReplacementCharacter;
559 QTest::newRow("invalid utf8") << QByteArray("hello\344h\344\344\366\344a\304") << str << -1;
560 QTest::newRow("invalid utf8-len") << QByteArray("hello\344h\344\344\366\344a\304") << QString("hello") << 5;
563 str += QChar::ReplacementCharacter;
564 str += QChar::ReplacementCharacter;
566 str += QChar::ReplacementCharacter;
568 str += QChar::ReplacementCharacter;
571 QTest::newRow("task28417") << QByteArray("Prohl\355\276e\350 plugin\371 Netscape") << str << -1;
572 QTest::newRow("task28417-len") << QByteArray("Prohl\355\276e\350 plugin\371 Netscape") << QString("") << 0;
574 QTest::newRow("null-1") << QByteArray() << QString() << -1;
575 QTest::newRow("null0") << QByteArray() << QString() << 0;
576 // QTest::newRow("null5") << QByteArray() << QString() << 5;
577 QTest::newRow("empty-1") << QByteArray("\0abcd", 5) << QString() << -1;
578 QTest::newRow("empty0") << QByteArray() << QString() << 0;
579 QTest::newRow("empty5") << QByteArray("\0abcd", 5) << QString::fromAscii("\0abcd", 5) << 5;
580 QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << QString::fromAscii("ab") << -1;
581 QTest::newRow("other5") << QByteArray("ab\0cd", 5) << QString::fromAscii("ab\0cd", 5) << 5;
583 str = "Old Italic: ";
584 str += QChar(0xd800);
585 str += QChar(0xdf00);
586 str += QChar(0xd800);
587 str += QChar(0xdf01);
588 str += QChar(0xd800);
589 str += QChar(0xdf02);
590 str += QChar(0xd800);
591 str += QChar(0xdf03);
592 str += QChar(0xd800);
593 str += QChar(0xdf04);
594 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;
596 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;
598 // from http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html
603 str = QChar(QChar::Null);
604 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.1") << utf8 << str << 1;
611 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.2") << utf8 << str << -1;
619 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.3") << utf8 << str << -1;
628 str += QChar(0xd800);
629 str += QChar(0xdc00);
630 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.4") << utf8 << str << -1;
632 // 2.1.5 U+00200000 (not a valid Unicode character)
639 str = fromInvalidUtf8Sequence(utf8);
640 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.5") << utf8 << str << -1;
642 // 2.1.6 U+04000000 (not a valid Unicode character)
650 str = fromInvalidUtf8Sequence(utf8);
651 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.6") << utf8 << str << -1;
657 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.1") << utf8 << str << -1;
664 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.2") << utf8 << str << -1;
672 str += QChar::ReplacementCharacter;
673 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.3") << utf8 << str << -1;
682 str += QChar(QChar::ReplacementCharacter);
683 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.4") << utf8 << str << -1;
685 // 2.2.5 U+03FFFFFF (not a valid Unicode character)
692 str = fromInvalidUtf8Sequence(utf8);
693 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.5") << utf8 << str << -1;
703 str = fromInvalidUtf8Sequence(utf8);
704 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.6") << utf8 << str << -1;
712 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.1") << utf8 << str << -1;
720 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.2") << utf8 << str << -1;
727 str = QChar(QChar::ReplacementCharacter);
728 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.3") << utf8 << str << -1;
737 str += QChar(0xdbff);
738 str += QChar(0xdffd);
739 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.4") << utf8 << str << -1;
748 str += QChar(QChar::ReplacementCharacter);
749 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.5") << utf8 << str << -1;
754 str = fromInvalidUtf8Sequence(utf8);
755 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.1") << utf8 << str << -1;
760 str = fromInvalidUtf8Sequence(utf8);
761 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.2") << utf8 << str << -1;
767 str = fromInvalidUtf8Sequence(utf8);
768 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.3") << utf8 << str << -1;
775 str = fromInvalidUtf8Sequence(utf8);
776 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.4") << utf8 << str << -1;
784 str = fromInvalidUtf8Sequence(utf8);
785 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.5") << utf8 << str << -1;
794 str = fromInvalidUtf8Sequence(utf8);
795 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.6") << utf8 << str << -1;
805 str = fromInvalidUtf8Sequence(utf8);
806 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.7") << utf8 << str << -1;
817 str = fromInvalidUtf8Sequence(utf8);
818 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.8") << utf8 << str << -1;
822 for (uint i = 0x80; i<= 0xbf; ++i)
824 str = fromInvalidUtf8Sequence(utf8);
825 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.9") << utf8 << str << -1;
830 for (uint i = 0xc8; i <= 0xdf; ++i) {
834 str += QChar::ReplacementCharacter;
835 str += QChar(0x0020);
837 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.1") << utf8 << str << -1;
842 for (uint i = 0xe0; i <= 0xef; ++i) {
846 str += QChar::ReplacementCharacter;
847 str += QChar(0x0020);
849 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.2") << utf8 << str << -1;
854 for (uint i = 0xf0; i <= 0xf7; ++i) {
858 str += QChar::ReplacementCharacter;
859 str += QChar(0x0020);
861 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.3") << utf8 << str << -1;
866 for (uint i = 0xf8; i <= 0xfb; ++i) {
870 str += QChar::ReplacementCharacter;
871 str += QChar(0x0020);
873 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.4") << utf8 << str << -1;
878 for (uint i = 0xfc; i <= 0xfd; ++i) {
882 str += QChar::ReplacementCharacter;
883 str += QChar(0x0020);
885 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.5") << utf8 << str << -1;
890 str = fromInvalidUtf8Sequence(utf8);
891 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.1") << utf8 << str << -1;
894 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.1-1") << utf8 << str << -1;
900 str = fromInvalidUtf8Sequence(utf8);
901 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2") << utf8 << str << -1;
904 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-1") << utf8 << str << -1;
908 str = fromInvalidUtf8Sequence(utf8);
909 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-2") << utf8 << str << -1;
912 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-3") << utf8 << str << -1;
919 str = fromInvalidUtf8Sequence(utf8);
920 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3") << utf8 << str << -1;
923 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-1") << utf8 << str << -1;
927 str = fromInvalidUtf8Sequence(utf8);
928 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-2") << utf8 << str << -1;
931 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-3") << utf8 << str << -1;
936 str = fromInvalidUtf8Sequence(utf8);
937 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-4") << utf8 << str << -1;
940 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-5") << utf8 << str << -1;
948 str = fromInvalidUtf8Sequence(utf8);
949 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4") << utf8 << str << -1;
952 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-1") << utf8 << str << -1;
958 str = fromInvalidUtf8Sequence(utf8);
959 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-2") << utf8 << str << -1;
962 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-3") << utf8 << str << -1;
967 str = fromInvalidUtf8Sequence(utf8);
968 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-4") << utf8 << str << -1;
971 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-5") << utf8 << str << -1;
975 str = fromInvalidUtf8Sequence(utf8);
976 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-6") << utf8 << str << -1;
979 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-7") << utf8 << str << -1;
988 str = fromInvalidUtf8Sequence(utf8);
989 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5") << utf8 << str << -1;
992 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-1") << utf8 << str << -1;
999 str = fromInvalidUtf8Sequence(utf8);
1000 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-2") << utf8 << str << -1;
1003 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-3") << utf8 << str << -1;
1009 str = fromInvalidUtf8Sequence(utf8);
1010 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-4") << utf8 << str << -1;
1013 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-5") << utf8 << str << -1;
1018 str = fromInvalidUtf8Sequence(utf8);
1019 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-6") << utf8 << str << -1;
1022 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-7") << utf8 << str << -1;
1026 str = fromInvalidUtf8Sequence(utf8);
1027 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-8") << utf8 << str << -1;
1030 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-9") << utf8 << str << -1;
1035 str = fromInvalidUtf8Sequence(utf8);
1036 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.6") << utf8 << str << -1;
1039 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.6-1") << utf8 << str << -1;
1045 str = fromInvalidUtf8Sequence(utf8);
1046 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7") << utf8 << str << -1;
1049 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-1") << utf8 << str << -1;
1053 str = fromInvalidUtf8Sequence(utf8);
1054 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-2") << utf8 << str << -1;
1057 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-3") << utf8 << str << -1;
1064 str = fromInvalidUtf8Sequence(utf8);
1065 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8") << utf8 << str << -1;
1068 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-1") << utf8 << str << -1;
1073 str = fromInvalidUtf8Sequence(utf8);
1074 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-2") << utf8 << str << -1;
1077 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-3") << utf8 << str << -1;
1081 str = fromInvalidUtf8Sequence(utf8);
1082 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-4") << utf8 << str << -1;
1085 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-5") << utf8 << str << -1;
1093 str = fromInvalidUtf8Sequence(utf8);
1094 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9") << utf8 << str << -1;
1097 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-1") << utf8 << str << -1;
1103 str = fromInvalidUtf8Sequence(utf8);
1104 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-2") << utf8 << str << -1;
1107 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-3") << utf8 << str << -1;
1112 str = fromInvalidUtf8Sequence(utf8);
1113 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-4") << utf8 << str << -1;
1116 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-5") << utf8 << str << -1;
1120 str = fromInvalidUtf8Sequence(utf8);
1121 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-6") << utf8 << str << -1;
1124 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-7") << utf8 << str << -1;
1133 str = fromInvalidUtf8Sequence(utf8);
1134 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10") << utf8 << str << -1;
1137 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-1") << utf8 << str << -1;
1144 str = fromInvalidUtf8Sequence(utf8);
1145 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-2") << utf8 << str << -1;
1148 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-3") << utf8 << str << -1;
1154 str = fromInvalidUtf8Sequence(utf8);
1155 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-4") << utf8 << str << -1;
1158 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-5") << utf8 << str << -1;
1163 str = fromInvalidUtf8Sequence(utf8);
1164 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-6") << utf8 << str << -1;
1167 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-7") << utf8 << str << -1;
1171 str = fromInvalidUtf8Sequence(utf8);
1172 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-8") << utf8 << str << -1;
1175 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-9") << utf8 << str << -1;
1209 str = fromInvalidUtf8Sequence(utf8);
1210 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.4") << utf8 << str << -1;
1215 str = fromInvalidUtf8Sequence(utf8);
1216 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.5.1") << utf8 << str << -1;
1221 str = fromInvalidUtf8Sequence(utf8);
1222 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.5.2") << utf8 << str << -1;
1229 str = fromInvalidUtf8Sequence(utf8);
1230 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.5.2-1") << utf8 << str << -1;
1236 str = QChar(QChar::ReplacementCharacter);
1237 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.1") << utf8 << str << -1;
1244 str = QChar(QChar::ReplacementCharacter);
1245 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.2") << utf8 << str << -1;
1253 str = QChar(QChar::ReplacementCharacter);
1254 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.3") << utf8 << str << -1;
1263 str = fromInvalidUtf8Sequence(utf8);
1264 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.4") << utf8 << str << -1;
1274 str = fromInvalidUtf8Sequence(utf8);
1275 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.5") << utf8 << str << -1;
1281 str = QChar(QChar::ReplacementCharacter);
1282 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.1") << utf8 << str << -1;
1289 str = QChar(QChar::ReplacementCharacter);
1290 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.2") << utf8 << str << -1;
1298 str = QChar(QChar::ReplacementCharacter);
1299 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.3") << utf8 << str << -1;
1308 str = fromInvalidUtf8Sequence(utf8);
1309 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.4") << utf8 << str << -1;
1319 str = fromInvalidUtf8Sequence(utf8);
1320 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.5") << utf8 << str << -1;
1326 str = QChar(QChar::ReplacementCharacter);
1327 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.1") << utf8 << str << -1;
1334 str = QChar(QChar::ReplacementCharacter);
1335 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.2") << utf8 << str << -1;
1343 str = QChar(QChar::ReplacementCharacter);
1344 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.3") << utf8 << str << -1;
1353 str = fromInvalidUtf8Sequence(utf8);
1354 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.4") << utf8 << str << -1;
1364 str = fromInvalidUtf8Sequence(utf8);
1365 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.5") << utf8 << str << -1;
1372 str = QChar(QChar::ReplacementCharacter);
1373 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.1") << utf8 << str << -1;
1380 str = QChar(QChar::ReplacementCharacter);
1381 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.2") << utf8 << str << -1;
1388 str = QChar(QChar::ReplacementCharacter);
1389 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.3") << utf8 << str << -1;
1396 str = QChar(QChar::ReplacementCharacter);
1397 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.4") << utf8 << str << -1;
1404 str = QChar(QChar::ReplacementCharacter);
1405 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.5") << utf8 << str << -1;
1412 str = QChar(QChar::ReplacementCharacter);
1413 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.6") << utf8 << str << -1;
1420 str = QChar(QChar::ReplacementCharacter);
1421 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.7") << utf8 << str << -1;
1432 str += QChar(QChar::ReplacementCharacter);
1433 str += QChar(QChar::ReplacementCharacter);
1434 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.1") << utf8 << str << -1;
1445 str += QChar(QChar::ReplacementCharacter);
1446 str += QChar(QChar::ReplacementCharacter);
1447 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.2") << utf8 << str << -1;
1458 str += QChar(QChar::ReplacementCharacter);
1459 str += QChar(QChar::ReplacementCharacter);
1460 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.3") << utf8 << str << -1;
1471 str += QChar(QChar::ReplacementCharacter);
1472 str += QChar(QChar::ReplacementCharacter);
1473 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.4") << utf8 << str << -1;
1484 str += QChar(QChar::ReplacementCharacter);
1485 str += QChar(QChar::ReplacementCharacter);
1486 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.5") << utf8 << str << -1;
1497 str += QChar(QChar::ReplacementCharacter);
1498 str += QChar(QChar::ReplacementCharacter);
1499 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.6") << utf8 << str << -1;
1510 str += QChar(QChar::ReplacementCharacter);
1511 str += QChar(QChar::ReplacementCharacter);
1512 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.7") << utf8 << str << -1;
1523 str += QChar(QChar::ReplacementCharacter);
1524 str += QChar(QChar::ReplacementCharacter);
1525 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.8") << utf8 << str << -1;
1532 str = QChar(QChar::ReplacementCharacter);
1533 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.3.1") << utf8 << str << -1;
1540 str = QChar(QChar::ReplacementCharacter);
1541 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.3.2") << utf8 << str << -1;
1544 void tst_QTextCodec::utf8Codec()
1546 QTextCodec *codec = QTextCodec::codecForMib(106); // UTF-8
1547 QVERIFY(codec != 0);
1549 QFETCH(QByteArray, utf8);
1550 QFETCH(QString, res);
1553 QString str = codec->toUnicode(utf8.isNull() ? 0 : utf8.constData(),
1554 len < 0 ? qstrlen(utf8.constData()) : len);
1557 str = QString::fromUtf8(utf8.isNull() ? 0 : utf8.constData(), len);
1561 void tst_QTextCodec::utf8bom_data()
1563 QTest::addColumn<QByteArray>("data");
1564 QTest::addColumn<QString>("result");
1566 QTest::newRow("nobom")
1567 << QByteArray("\302\240", 2)
1571 static const ushort data[] = { 0x201d };
1572 QTest::newRow("nobom 2")
1573 << QByteArray("\342\200\235", 3)
1574 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1578 static const ushort data[] = { 0xf000 };
1579 QTest::newRow("bom1")
1580 << QByteArray("\357\200\200", 3)
1581 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1585 static const ushort data[] = { 0xfec0 };
1586 QTest::newRow("bom2")
1587 << QByteArray("\357\273\200", 3)
1588 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1592 QTest::newRow("normal-bom")
1593 << QByteArray("\357\273\277a", 4)
1598 static const ushort data[] = { 0x61, 0xfeff, 0x62 };
1599 QTest::newRow("middle-bom")
1600 << QByteArray("a\357\273\277b", 5)
1601 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1605 void tst_QTextCodec::utf8bom()
1607 QFETCH(QByteArray, data);
1608 QFETCH(QString, result);
1610 QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
1613 QCOMPARE(codec->toUnicode(data.constData(), data.length(), 0), result);
1615 QTextCodec::ConverterState state;
1616 QCOMPARE(codec->toUnicode(data.constData(), data.length(), &state), result);
1619 void tst_QTextCodec::utfHeaders_data()
1621 QTest::addColumn<QByteArray>("codecName");
1622 QTest::addColumn<int>("flags");
1623 QTest::addColumn<QByteArray>("encoded");
1624 QTest::addColumn<QString>("unicode");
1625 QTest::addColumn<bool>("toUnicode");
1627 QTest::newRow("utf8 bom")
1628 << QByteArray("UTF-8")
1630 << QByteArray("\xef\xbb\xbfhello")
1631 << QString::fromLatin1("hello")
1633 QTest::newRow("utf8 nobom")
1634 << QByteArray("UTF-8")
1636 << QByteArray("hello")
1637 << QString::fromLatin1("hello")
1639 QTest::newRow("utf8 bom ignore header")
1640 << QByteArray("UTF-8")
1641 << (int)QTextCodec::IgnoreHeader
1642 << QByteArray("\xef\xbb\xbfhello")
1643 << (QString(QChar(0xfeff)) + QString::fromLatin1("hello"))
1645 QTest::newRow("utf8 nobom ignore header")
1646 << QByteArray("UTF-8")
1647 << (int)QTextCodec::IgnoreHeader
1648 << QByteArray("hello")
1649 << QString::fromLatin1("hello")
1652 QTest::newRow("utf16 bom be")
1653 << QByteArray("UTF-16")
1655 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1656 << QString::fromLatin1("hel")
1658 QTest::newRow("utf16 bom le")
1659 << QByteArray("UTF-16")
1661 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1662 << QString::fromLatin1("hel")
1664 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
1665 QTest::newRow("utf16 nobom")
1666 << QByteArray("UTF-16")
1668 << QByteArray("\0h\0e\0l", 6)
1669 << QString::fromLatin1("hel")
1671 QTest::newRow("utf16 bom be ignore header")
1672 << QByteArray("UTF-16")
1673 << (int)QTextCodec::IgnoreHeader
1674 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1675 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1678 QTest::newRow("utf16 nobom")
1679 << QByteArray("UTF-16")
1681 << QByteArray("h\0e\0l\0", 6)
1682 << QString::fromLatin1("hel")
1684 QTest::newRow("utf16 bom le ignore header")
1685 << QByteArray("UTF-16")
1686 << (int)QTextCodec::IgnoreHeader
1687 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1688 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1692 QTest::newRow("utf16-be bom be")
1693 << QByteArray("UTF-16BE")
1695 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1696 << QString::fromLatin1("hel")
1698 QTest::newRow("utf16-be nobom")
1699 << QByteArray("UTF-16BE")
1701 << QByteArray("\0h\0e\0l", 6)
1702 << QString::fromLatin1("hel")
1704 QTest::newRow("utf16-be bom be ignore header")
1705 << QByteArray("UTF-16BE")
1706 << (int)QTextCodec::IgnoreHeader
1707 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1708 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1711 QTest::newRow("utf16-le bom le")
1712 << QByteArray("UTF-16LE")
1714 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1715 << QString::fromLatin1("hel")
1717 QTest::newRow("utf16-le nobom")
1718 << QByteArray("UTF-16LE")
1720 << QByteArray("h\0e\0l\0", 6)
1721 << QString::fromLatin1("hel")
1723 QTest::newRow("utf16-le bom le ignore header")
1724 << QByteArray("UTF-16LE")
1725 << (int)QTextCodec::IgnoreHeader
1726 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1727 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1731 QTest::newRow("utf32 bom be")
1732 << QByteArray("UTF-32")
1734 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1735 << QString::fromLatin1("hel")
1737 QTest::newRow("utf32 bom le")
1738 << QByteArray("UTF-32")
1740 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1741 << QString::fromLatin1("hel")
1743 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
1744 QTest::newRow("utf32 nobom")
1745 << QByteArray("UTF-32")
1747 << QByteArray("\0\0\0h\0\0\0e\0\0\0l", 12)
1748 << QString::fromLatin1("hel")
1750 QTest::newRow("utf32 bom be ignore header")
1751 << QByteArray("UTF-32")
1752 << (int)QTextCodec::IgnoreHeader
1753 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1754 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1757 QTest::newRow("utf32 nobom")
1758 << QByteArray("UTF-32")
1760 << QByteArray("h\0\0\0e\0\0\0l\0\0\0", 12)
1761 << QString::fromLatin1("hel")
1763 QTest::newRow("utf32 bom le ignore header")
1764 << QByteArray("UTF-32")
1765 << (int)QTextCodec::IgnoreHeader
1766 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1767 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1772 QTest::newRow("utf32-be bom be")
1773 << QByteArray("UTF-32BE")
1775 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1776 << QString::fromLatin1("hel")
1778 QTest::newRow("utf32-be nobom")
1779 << QByteArray("UTF-32BE")
1781 << QByteArray("\0\0\0h\0\0\0e\0\0\0l", 12)
1782 << QString::fromLatin1("hel")
1784 QTest::newRow("utf32-be bom be ignore header")
1785 << QByteArray("UTF-32BE")
1786 << (int)QTextCodec::IgnoreHeader
1787 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1788 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1792 QTest::newRow("utf32-le bom le")
1793 << QByteArray("UTF-32LE")
1795 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1796 << QString::fromLatin1("hel")
1798 QTest::newRow("utf32-le nobom")
1799 << QByteArray("UTF-32LE")
1801 << QByteArray("h\0\0\0e\0\0\0l\0\0\0", 12)
1802 << QString::fromLatin1("hel")
1804 QTest::newRow("utf32-le bom le ignore header")
1805 << QByteArray("UTF-32LE")
1806 << (int)QTextCodec::IgnoreHeader
1807 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1808 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1812 void tst_QTextCodec::utfHeaders()
1814 QFETCH(QByteArray, codecName);
1815 QTextCodec *codec = QTextCodec::codecForName(codecName);
1816 QVERIFY(codec != 0);
1819 QTextCodec::ConversionFlags cFlags = QTextCodec::ConversionFlags(flags);
1820 QTextCodec::ConverterState state(cFlags);
1822 QFETCH(QByteArray, encoded);
1823 QFETCH(QString, unicode);
1825 QFETCH(bool, toUnicode);
1827 QLatin1String ignoreReverseTestOn = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? QLatin1String(" le") : QLatin1String(" be");
1828 QString rowName(QTest::currentDataTag());
1831 QString result = codec->toUnicode(encoded.constData(), encoded.length(), &state);
1832 QCOMPARE(result.length(), unicode.length());
1833 QCOMPARE(result, unicode);
1835 if (!rowName.endsWith("nobom") && !rowName.contains(ignoreReverseTestOn)) {
1836 QTextCodec::ConverterState state2(cFlags);
1837 QByteArray reencoded = codec->fromUnicode(unicode.unicode(), unicode.length(), &state2);
1838 QCOMPARE(reencoded, encoded);
1841 QByteArray result = codec->fromUnicode(unicode.unicode(), unicode.length(), &state);
1842 QCOMPARE(result, encoded);
1846 void tst_QTextCodec::codecForHtml()
1848 QByteArray html("<html><head></head><body>blah</body></html>");
1850 QCOMPARE(QTextCodec::codecForHtml(html)->mibEnum(), 4); // latin 1
1852 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 106); // UTF-8
1854 html = "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-15\" /></head></html>";
1855 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 111); // latin 15
1857 html = "<html><head><meta content=\"text/html; charset=ISO-8859-15\" http-equiv=\"content-type\" /></head></html>";
1858 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 111); // latin 15
1860 html = "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=invalid-foo\" /></head></html>";
1861 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 106); // UTF-8
1862 QCOMPARE(QTextCodec::codecForHtml(html)->mibEnum(), 4); // latin 1
1865 void tst_QTextCodec::codecForUtfText_data()
1867 QTest::addColumn<QByteArray>("encoded");
1868 QTest::addColumn<bool>("detected");
1869 QTest::addColumn<int>("mib");
1872 QTest::newRow("utf8 bom")
1873 << QByteArray("\xef\xbb\xbfhello")
1876 QTest::newRow("utf8 nobom")
1877 << QByteArray("hello")
1881 QTest::newRow("utf16 bom be")
1882 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1885 QTest::newRow("utf16 bom le")
1886 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1889 QTest::newRow("utf16 nobom")
1890 << QByteArray("\0h\0e\0l", 6)
1894 QTest::newRow("utf32 bom be")
1895 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1898 QTest::newRow("utf32 bom le")
1899 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1902 QTest::newRow("utf32 nobom")
1903 << QByteArray("\0\0\0h\0\0\0e\0\0\0l", 12)
1908 void tst_QTextCodec::codecForUtfText()
1910 QFETCH(QByteArray, encoded);
1911 QFETCH(bool, detected);
1914 QTextCodec *codec = QTextCodec::codecForUtfText(encoded, 0);
1916 QCOMPARE(codec->mibEnum(), mib);
1918 QVERIFY(codec == 0);
1921 #if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
1922 void tst_QTextCodec::toLocal8Bit()
1925 process.start("echo/echo");
1926 QString string(QChar(0x410));
1927 process.write((const char*)string.utf16(), string.length()*2);
1929 process.closeWriteChannel();
1930 process.waitForFinished();
1931 QCOMPARE(process.exitStatus(), QProcess::NormalExit);
1932 QCOMPARE(process.exitCode(), 0);
1936 class LoadAndConvert: public QRunnable
1939 LoadAndConvert(const QByteArray &source, QByteArray *destination)
1940 : codecName(source), target(destination)
1942 QByteArray codecName;
1946 QTextCodec *c = QTextCodec::codecForName(codecName);
1948 qWarning() << "WARNING" << codecName << "not found?";
1951 QString str = QString::fromLatin1(codecName);
1952 QByteArray b = c->fromUnicode(str);
1954 *target = codecName;
1958 class LoadAndConvertMIB: public QRunnable
1961 LoadAndConvertMIB(int mib, int *target)
1962 : mib(mib), target(target)
1968 QTextCodec *c = QTextCodec::codecForMib(mib);
1970 qWarning() << "WARNING" << mib << "not found?";
1973 QString str = QString::number(mib);
1974 QByteArray b = c->fromUnicode(str);
1981 void tst_QTextCodec::threadSafety()
1983 QList<QByteArray> codecList = QTextCodec::availableCodecs();
1984 QList<int> mibList = QTextCodec::availableMibs();
1985 QThreadPool::globalInstance()->setMaxThreadCount(12);
1987 QVector<QByteArray> res;
1988 res.resize(codecList.size());
1989 for (int i = 0; i < codecList.size(); ++i) {
1990 QThreadPool::globalInstance()->start(new LoadAndConvert(codecList.at(i), &res[i]));
1994 res2.resize(mibList.size());
1995 for (int i = 0; i < mibList.size(); ++i) {
1996 QThreadPool::globalInstance()->start(new LoadAndConvertMIB(mibList.at(i), &res2[i]));
1999 // wait for all threads to finish working
2000 QThreadPool::globalInstance()->waitForDone();
2002 QCOMPARE(res.toList(), codecList);
2003 QCOMPARE(res2.toList(), mibList);
2006 void tst_QTextCodec::invalidNames()
2008 QVERIFY(!QTextCodec::codecForName(""));
2009 QVERIFY(!QTextCodec::codecForName(QByteArray()));
2010 QVERIFY(!QTextCodec::codecForName("-"));
2011 QVERIFY(!QTextCodec::codecForName("\1a\2b\3a\4d\5c\6s\7a\xffr\xec_\x9c_"));
2012 QVERIFY(!QTextCodec::codecForName("\n"));
2013 QVERIFY(!QTextCodec::codecForName("don't exist"));
2014 QByteArray huge = "azertyuiop^$qsdfghjklm<wxcvbn,;:=1234567890�_";
2015 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2016 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2017 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2018 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2019 QVERIFY(!QTextCodec::codecForName(huge));
2022 void tst_QTextCodec::checkAliases_data()
2024 QTest::addColumn<QByteArray>("codecName");
2025 QList<QByteArray> codecList = QTextCodec::availableCodecs();
2026 foreach (const QByteArray &a, codecList) {
2027 QTest::newRow( a.constData() ) << a;
2031 void tst_QTextCodec::checkAliases()
2033 QFETCH( QByteArray, codecName );
2034 QTextCodec *c = QTextCodec::codecForName(codecName);
2036 QCOMPARE(QTextCodec::codecForName(codecName), c);
2037 QCOMPARE(QTextCodec::codecForName(c->name()), c);
2039 foreach(const QByteArray &a, c->aliases()) {
2040 QCOMPARE(QTextCodec::codecForName(a), c);
2045 void tst_QTextCodec::moreToFromUnicode_data() {
2046 QTest::addColumn<QByteArray>("codecName");
2047 QTest::addColumn<QByteArray>("testData");
2049 QTest::newRow("russian") << QByteArray("ISO-8859-5")
2050 << 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");
2052 QTest::newRow("arabic") << QByteArray("ISO-8859-6")
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\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");
2055 QTest::newRow("greek") << QByteArray("ISO-8859-7")
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\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");
2058 QTest::newRow("turkish") << QByteArray("ISO-8859-9")
2059 << 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");
2061 QTest::newRow("latin1") << QByteArray("ISO-8859-1")
2062 << 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");
2064 QByteArray sms7bit_ba;
2065 for (int i=1; i <= 0x7f; ++i) {
2067 sms7bit_ba.append(i);
2071 QTest::newRow("latin2") << QByteArray("ISO-8859-2")
2072 << 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");
2074 QTest::newRow("latin3") << QByteArray("ISO-8859-3")
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\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");
2077 QTest::newRow("latin4") << QByteArray("ISO-8859-4")
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\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");
2080 QTest::newRow("russian 2") << QByteArray("ISO-8859-5")
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("arabic 2") << QByteArray("ISO-8859-6")
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\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");
2086 QTest::newRow("greek 2") << QByteArray("ISO-8859-7")
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\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");
2089 QTest::newRow("latin5") << QByteArray("ISO-8859-9")
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\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");
2092 QTest::newRow("latin6") << QByteArray("ISO-8859-10")
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");
2096 QByteArray iso8859_11_ba;
2097 for (int x=0x20; x<=0x7f; ++x) {
2098 iso8859_11_ba.append(x);
2100 for (int x=0xa0; x<0xff; ++x) {
2101 if ((x>=0xdb && x<0xdf) || x>0xfb){
2104 iso8859_11_ba.append(x);
2106 QTest::newRow("latin-thai") << QByteArray("ISO-8859-11") << iso8859_11_ba;
2109 QTest::newRow("latin7") << QByteArray("ISO-8859-13")
2110 << 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");
2112 QTest::newRow("celtic") << QByteArray("ISO-8859-14")
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("latin9") << QByteArray("ISO-8859-15")
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("latin10") << QByteArray("ISO-8859-16")
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("cp850") << QByteArray("CP850")
2122 << 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");
2124 QTest::newRow("cp874") << QByteArray("CP874")
2125 << 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");
2127 QTest::newRow("cp1250") << QByteArray("CP1250")
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\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");
2130 QTest::newRow("cp1251") << QByteArray("CP1251")
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\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");
2133 QTest::newRow("cp1252") << QByteArray("CP1252")
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\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");
2136 QTest::newRow("cp1253") << QByteArray("CP1253")
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\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");
2139 QTest::newRow("cp1254") << QByteArray("CP1254")
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\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");
2142 QTest::newRow("cp1255") << QByteArray("CP1255")
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,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");
2145 QTest::newRow("cp1256") << QByteArray("CP1256")
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\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");
2148 QTest::newRow("cp1257") << QByteArray("CP1257")
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\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");
2151 QTest::newRow("cp1258") << QByteArray("CP1258")
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\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");
2154 QByteArray koi8_r_ba;
2155 for (int x=0x20; x<=0xff; ++x) {
2156 if (x!=0x9A && x!=0xbf) {
2157 koi8_r_ba.append(x);
2160 QTest::newRow("KOI8-R") << QByteArray("KOI8-R") << koi8_r_ba;
2162 QByteArray koi8_u_ba;
2163 for (int x=0x20; x<=0xff; ++x) {
2164 koi8_u_ba.append(x);
2166 QTest::newRow("KOI8-U") << QByteArray("KOI8-U") << koi8_u_ba;
2170 for (unsigned char u=0xa1; u<=0xf9; u++) {
2174 for (unsigned char v=0x40; v<=0x7e; v++) {
2180 case 0xa3: v_up=0xbf; break;
2181 case 0xc7: v_up=0xfc; break;
2182 case 0xf9: v_up=0xd5; break;
2186 for (unsigned char v=0xa1; v<=v_up; v++) {
2187 if (u==0xa2 && (v==0xcc || v==0xce)) {
2195 QTest::newRow("BIG5") << QByteArray("BIG5") << big5_ba;
2197 QByteArray gb2312_ba;
2198 for (unsigned char u=0xa1; u<=0xf7; u++) {
2199 for (unsigned char v=0xa1; v<=0xfe; v++) {
2200 gb2312_ba.append(u);
2201 gb2312_ba.append(v);
2205 QTest::newRow("GB2312") << QByteArray("GB2312") << gb2312_ba;
2208 void tst_QTextCodec::moreToFromUnicode()
2210 QFETCH( QByteArray, codecName );
2211 QFETCH( QByteArray, testData );
2213 QTextCodec *c = QTextCodec::codecForName( codecName.data() );
2216 QString uStr = c->toUnicode(testData);
2217 QByteArray cStr = c->fromUnicode(uStr);
2218 QCOMPARE(testData, cStr);
2221 void tst_QTextCodec::shiftJis()
2223 QByteArray backslashTilde("\\~");
2224 QTextCodec* codec = QTextCodec::codecForName("shift_jis");
2225 QString string = codec->toUnicode(backslashTilde);
2226 QCOMPARE(string.length(), 2);
2227 QCOMPARE(string.at(0), QChar(QLatin1Char('\\')));
2228 QCOMPARE(string.at(1), QChar(QLatin1Char('~')));
2230 QByteArray encoded = codec->fromUnicode(string);
2231 QCOMPARE(encoded, backslashTilde);
2234 struct DontCrashAtExit {
2235 ~DontCrashAtExit() {
2236 QTextCodec *c = QTextCodec::codecForName("utf8");
2238 c->toUnicode("azerty");
2244 QTEST_MAIN(tst_QTextCodec)
2245 #include "tst_qtextcodec.moc"