1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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;
76 void codecForTSCII() const;
78 void utf8Codec_data();
84 void utfHeaders_data();
89 void codecForUtfText_data();
90 void codecForUtfText();
92 #if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
97 void checkAliases_data();
100 void moreToFromUnicode_data();
101 void moreToFromUnicode();
106 void tst_QTextCodec::toUnicode_data()
108 QTest::addColumn<QString>("fileName");
109 QTest::addColumn<QString>("codecName");
111 QTest::newRow( "korean-eucKR" ) << QFINDTESTDATA("korean.txt") << "eucKR";
112 QTest::newRow( "UTF-8" ) << QFINDTESTDATA("utf8.txt") << "UTF-8";
115 void tst_QTextCodec::toUnicode()
117 QFETCH( QString, fileName );
118 QFETCH( QString, codecName );
120 QFile file( fileName );
122 if ( file.open( QIODevice::ReadOnly ) ) {
123 QByteArray ba = file.readAll();
124 QVERIFY(!ba.isEmpty());
125 QTextCodec *c = QTextCodec::codecForName( codecName.toLatin1() );
127 QString uniString = c->toUnicode( ba );
128 if (codecName == QLatin1String("UTF-8")) {
129 QCOMPARE(uniString, QString::fromUtf8(ba));
130 QCOMPARE(ba, uniString.toUtf8());
132 QVERIFY(!uniString.isEmpty());
133 QCOMPARE( ba, c->fromUnicode( uniString ) );
136 QVERIFY(c->toUnicode(&ch, 1).length() == 1);
137 QVERIFY(c->toUnicode(&ch, 1).at(0).unicode() == 0);
139 QFAIL(qPrintable("File could not be opened: " + file.errorString()));
143 void tst_QTextCodec::codecForName_data()
145 QTest::addColumn<QString>("hint");
146 QTest::addColumn<QString>("actualCodecName");
148 QTest::newRow("data1") << "iso88591" << "ISO-8859-1";
149 QTest::newRow("data2") << "iso88592" << "ISO-8859-2";
150 QTest::newRow("data3") << " IsO(8)8/5*9-2 " << "ISO-8859-2";
151 QTest::newRow("data4") << " IsO(8)8/5*2-9 " << "";
152 QTest::newRow("data5") << "latin2" << "ISO-8859-2";
155 void tst_QTextCodec::codecForName()
157 QFETCH(QString, hint);
158 QFETCH(QString, actualCodecName);
160 QTextCodec *codec = QTextCodec::codecForName(hint.toLatin1());
161 if (actualCodecName.isEmpty()) {
165 QCOMPARE(QString(codec->name()), actualCodecName);
169 void tst_QTextCodec::fromUnicode_data()
171 QTest::addColumn<QString>("codecName");
172 QTest::addColumn<bool>("eightBit");
174 QTest::newRow("ISO-8859-1") << "ISO-8859-1" << true;
175 QTest::newRow("ISO-8859-2") << "ISO-8859-2" << true;
176 QTest::newRow("ISO-8859-3") << "ISO-8859-3" << true;
177 QTest::newRow("ISO-8859-4") << "ISO-8859-4" << true;
178 QTest::newRow("ISO-8859-5") << "ISO-8859-5" << true;
179 QTest::newRow("ISO-8859-6") << "ISO-8859-6" << true;
180 QTest::newRow("ISO-8859-7") << "ISO-8859-7" << true;
181 QTest::newRow("ISO-8859-8") << "ISO-8859-8" << true;
182 QTest::newRow("ISO-8859-9") << "ISO-8859-9" << true;
183 QTest::newRow("ISO-8859-10") << "ISO-8859-10" << true;
184 QTest::newRow("ISO-8859-13") << "ISO-8859-13" << true;
185 QTest::newRow("ISO-8859-14") << "ISO-8859-14" << true;
186 QTest::newRow("ISO-8859-15") << "ISO-8859-15" << true;
187 // QTest::newRow("ISO-8859-16") << "ISO-8859-16" << true;
189 QTest::newRow("IBM850") << "IBM850" << true;
190 QTest::newRow("IBM874") << "IBM874" << true;
191 QTest::newRow("IBM866") << "IBM866" << true;
193 QTest::newRow("windows-1250") << "windows-1250" << true;
194 QTest::newRow("windows-1251") << "windows-1251" << true;
195 QTest::newRow("windows-1252") << "windows-1252" << true;
196 QTest::newRow("windows-1253") << "windows-1253" << true;
197 QTest::newRow("windows-1254") << "windows-1254" << true;
198 QTest::newRow("windows-1255") << "windows-1255" << true;
199 QTest::newRow("windows-1256") << "windows-1256" << true;
200 QTest::newRow("windows-1257") << "windows-1257" << true;
201 QTest::newRow("windows-1258") << "windows-1258" << true;
203 QTest::newRow("macintosh") << "macintosh" << true;
204 //QTest::newRow("WINSAMI2") << "WINSAMI2" << true;
205 QTest::newRow("TIS-620") << "TIS-620" << true;
206 // QTest::newRow("hp-roman8") << "hp-roman8" << true;
207 QTest::newRow("SJIS") << "SJIS" << false;
209 // all codecs from documentation
210 QTest::newRow("Big5") << "Big5" << false;
211 QTest::newRow("Big5-HKSCS") << "Big5-HKSCS" << false;
212 QTest::newRow("CP949") << "CP949" << false;
213 QTest::newRow("windows-949") << "windows-949" << 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]);
397 QSKIP("No ISCII codecs available.");
399 for(int i2 = 0; i2 < len; ++i2) {
400 /* For each character in ascii. */
401 const QChar c(ascii[i2]);
402 QVERIFY2(textCodec->canEncode(c), qPrintable(QString::fromLatin1("Failed to encode %1 with encoding %2")
403 .arg(QString::number(c.unicode()), QString::fromLatin1(textCodec->name().constData()))));
406 QVERIFY2(textCodec->canEncode(ascii), qPrintable(QString::fromLatin1("Failed for full string with encoding %1")
407 .arg(QString::fromLatin1(textCodec->name().constData()))));
411 void tst_QTextCodec::flagCodepointFFFF() const
413 // This is an invalid Unicode codepoint.
414 const QChar ch(0xFFFF);
417 QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
420 const QByteArray asDecoded(codec->fromUnicode(input));
421 QCOMPARE(asDecoded, QByteArray("?"));
423 QByteArray ffff("\357\277\277");
424 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
425 QVERIFY(codec->toUnicode(ffff.constData(), ffff.length(), &state) == QChar(0));
426 QVERIFY(codec->toUnicode(ffff) == QChar(0xfffd));
429 void tst_QTextCodec::flagF7808080() const
431 /* This test case stems from test not-wf-sa-170, tests/qxmlstream/XML-Test-Suite/xmlconf/xmltest/not-wf/sa/166.xml,
432 * whose description reads:
434 * "Four byte UTF-8 encodings can encode UCS-4 characters
435 * which are beyond the range of legal XML characters
436 * (and can't be expressed in Unicode surrogate pairs).
437 * This document holds such a character."
439 * In binary, this is:
440 * 11110111100000001000000010000000
442 * 11110www10xxxxxx10yyyyyy10zzzzzz
444 * With multibyte logic removed it is the codepoint 0x1C0000.
448 input[0] = char(0xF7);
449 input[1] = char(0x80);
450 input[2] = char(0x80);
451 input[3] = char(0x80);
453 QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
456 //QVERIFY(!codec->canEncode(QChar(0x1C0000)));
458 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
459 QVERIFY(codec->toUnicode(input.constData(), input.length(), &state) == QChar(0));
462 void tst_QTextCodec::flagEFBFBF() const
464 QByteArray invalidInput;
465 invalidInput.resize(3);
466 invalidInput[0] = char(0xEF);
467 invalidInput[1] = char(0xBF);
468 invalidInput[2] = char(0xBF);
470 const QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
474 //QVERIFY(!codec->canEncode(QChar(0xFFFF)));
475 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
476 QVERIFY(codec->toUnicode(invalidInput.constData(), invalidInput.length(), &state) == QChar(0));
478 QByteArray start("<?pi ");
479 start.append(invalidInput);
483 /* When 0xEFBFBF is preceded by what seems to be an arbitrary character,
484 * QTextCodec fails to flag it. */
486 QByteArray start("B");
487 start.append(invalidInput);
489 QTextCodec::ConverterState state(QTextCodec::ConvertInvalidToNull);
490 QVERIFY(codec->toUnicode(start.constData(), start.length(), &state) == QString::fromLatin1("B\0", 2));
494 void tst_QTextCodec::decode0D() const
502 QCOMPARE(QString::fromUtf8(input.constData()).toUtf8(), input);
505 void tst_QTextCodec::aliasForUTF16() const
507 QVERIFY(QTextCodec::codecForName("UTF-16")->aliases().isEmpty());
510 void tst_QTextCodec::mibForTSCII() const
512 QTextCodec *codec = QTextCodec::codecForName("TSCII");
514 QCOMPARE(codec->mibEnum(), 2107);
517 void tst_QTextCodec::codecForTSCII() const
519 QTextCodec *codec = QTextCodec::codecForMib(2107);
521 QCOMPARE(codec->mibEnum(), 2107);
524 static QString fromInvalidUtf8Sequence(const QByteArray &ba)
526 return QString().fill(QChar::ReplacementCharacter, ba.size());
529 // copied from tst_QString::fromUtf8_data()
530 void tst_QTextCodec::utf8Codec_data()
532 QTest::addColumn<QByteArray>("utf8");
533 QTest::addColumn<QString>("res");
534 QTest::addColumn<int>("len");
537 QTest::newRow("str0") << QByteArray("abcdefgh") << QString("abcdefgh") << -1;
538 QTest::newRow("str0-len") << QByteArray("abcdefgh") << QString("abc") << 3;
539 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")
540 << QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305") << -1;
541 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")
542 << QString::fromLatin1("\366\344\374\326\304") << 10;
544 str += QChar(0x05e9);
545 str += QChar(0x05d3);
546 str += QChar(0x05d2);
547 QTest::newRow("str2") << QByteArray("\327\251\327\223\327\222") << str << -1;
550 QTest::newRow("str2-len") << QByteArray("\327\251\327\223\327\222") << str << 2;
554 QTest::newRow("str3") << QByteArray("\342\202\254 some text") << str << -1;
558 QTest::newRow("str3-len") << QByteArray("\342\202\254 some text") << str << 9;
561 str += QChar::ReplacementCharacter;
563 str += QChar::ReplacementCharacter;
564 str += QChar::ReplacementCharacter;
565 str += QChar::ReplacementCharacter;
566 str += QChar::ReplacementCharacter;
568 str += QChar::ReplacementCharacter;
569 QTest::newRow("invalid utf8") << QByteArray("hello\344h\344\344\366\344a\304") << str << -1;
570 QTest::newRow("invalid utf8-len") << QByteArray("hello\344h\344\344\366\344a\304") << QString("hello") << 5;
573 str += QChar::ReplacementCharacter;
574 str += QChar::ReplacementCharacter;
576 str += QChar::ReplacementCharacter;
578 str += QChar::ReplacementCharacter;
581 QTest::newRow("task28417") << QByteArray("Prohl\355\276e\350 plugin\371 Netscape") << str << -1;
582 QTest::newRow("task28417-len") << QByteArray("Prohl\355\276e\350 plugin\371 Netscape") << QString("") << 0;
584 QTest::newRow("null-1") << QByteArray() << QString() << -1;
585 QTest::newRow("null0") << QByteArray() << QString() << 0;
586 // QTest::newRow("null5") << QByteArray() << QString() << 5;
587 QTest::newRow("empty-1") << QByteArray("\0abcd", 5) << QString() << -1;
588 QTest::newRow("empty0") << QByteArray() << QString() << 0;
589 QTest::newRow("empty5") << QByteArray("\0abcd", 5) << QString::fromLatin1("\0abcd", 5) << 5;
590 QTest::newRow("other-1") << QByteArray("ab\0cd", 5) << QString::fromLatin1("ab") << -1;
591 QTest::newRow("other5") << QByteArray("ab\0cd", 5) << QString::fromLatin1("ab\0cd", 5) << 5;
593 str = "Old Italic: ";
594 str += QChar(0xd800);
595 str += QChar(0xdf00);
596 str += QChar(0xd800);
597 str += QChar(0xdf01);
598 str += QChar(0xd800);
599 str += QChar(0xdf02);
600 str += QChar(0xd800);
601 str += QChar(0xdf03);
602 str += QChar(0xd800);
603 str += QChar(0xdf04);
604 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;
606 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;
608 // from http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html
613 str = QChar(QChar::Null);
614 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.1") << utf8 << str << 1;
621 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.2") << utf8 << str << -1;
629 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.3") << utf8 << str << -1;
638 str += QChar(0xd800);
639 str += QChar(0xdc00);
640 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.4") << utf8 << str << -1;
642 // 2.1.5 U+00200000 (not a valid Unicode character)
649 str = fromInvalidUtf8Sequence(utf8);
650 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.5") << utf8 << str << -1;
652 // 2.1.6 U+04000000 (not a valid Unicode character)
660 str = fromInvalidUtf8Sequence(utf8);
661 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.1.6") << utf8 << str << -1;
667 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.1") << utf8 << str << -1;
674 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.2") << utf8 << str << -1;
682 str += QChar::ReplacementCharacter;
683 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.3") << utf8 << str << -1;
692 str += QChar(QChar::ReplacementCharacter);
693 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.4") << utf8 << str << -1;
695 // 2.2.5 U+03FFFFFF (not a valid Unicode character)
702 str = fromInvalidUtf8Sequence(utf8);
703 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.5") << utf8 << str << -1;
713 str = fromInvalidUtf8Sequence(utf8);
714 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.2.6") << utf8 << str << -1;
722 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.1") << utf8 << str << -1;
730 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.2") << utf8 << str << -1;
737 str = QChar(QChar::ReplacementCharacter);
738 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.3") << utf8 << str << -1;
747 str += QChar(0xdbff);
748 str += QChar(0xdffd);
749 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.4") << utf8 << str << -1;
758 str += QChar(QChar::ReplacementCharacter);
759 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 2.3.5") << utf8 << str << -1;
764 str = fromInvalidUtf8Sequence(utf8);
765 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.1") << 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.2") << utf8 << str << -1;
777 str = fromInvalidUtf8Sequence(utf8);
778 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.3") << utf8 << str << -1;
785 str = fromInvalidUtf8Sequence(utf8);
786 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.4") << 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.5") << utf8 << str << -1;
804 str = fromInvalidUtf8Sequence(utf8);
805 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.6") << utf8 << str << -1;
815 str = fromInvalidUtf8Sequence(utf8);
816 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.7") << utf8 << str << -1;
827 str = fromInvalidUtf8Sequence(utf8);
828 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.8") << utf8 << str << -1;
832 for (uint i = 0x80; i<= 0xbf; ++i)
834 str = fromInvalidUtf8Sequence(utf8);
835 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.1.9") << utf8 << str << -1;
840 for (uint i = 0xc8; i <= 0xdf; ++i) {
844 str += QChar::ReplacementCharacter;
845 str += QChar(0x0020);
847 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.1") << utf8 << str << -1;
852 for (uint i = 0xe0; i <= 0xef; ++i) {
856 str += QChar::ReplacementCharacter;
857 str += QChar(0x0020);
859 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.2") << utf8 << str << -1;
864 for (uint i = 0xf0; i <= 0xf7; ++i) {
868 str += QChar::ReplacementCharacter;
869 str += QChar(0x0020);
871 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.3") << utf8 << str << -1;
876 for (uint i = 0xf8; i <= 0xfb; ++i) {
880 str += QChar::ReplacementCharacter;
881 str += QChar(0x0020);
883 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.4") << utf8 << str << -1;
888 for (uint i = 0xfc; i <= 0xfd; ++i) {
892 str += QChar::ReplacementCharacter;
893 str += QChar(0x0020);
895 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.2.5") << 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.1") << utf8 << str << -1;
904 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.1-1") << utf8 << str << -1;
910 str = fromInvalidUtf8Sequence(utf8);
911 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2") << utf8 << str << -1;
914 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-1") << utf8 << str << -1;
918 str = fromInvalidUtf8Sequence(utf8);
919 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-2") << utf8 << str << -1;
922 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.2-3") << utf8 << str << -1;
929 str = fromInvalidUtf8Sequence(utf8);
930 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3") << utf8 << str << -1;
933 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-1") << utf8 << str << -1;
937 str = fromInvalidUtf8Sequence(utf8);
938 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-2") << utf8 << str << -1;
941 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-3") << utf8 << str << -1;
946 str = fromInvalidUtf8Sequence(utf8);
947 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-4") << utf8 << str << -1;
950 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.3-5") << 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") << utf8 << str << -1;
962 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-1") << utf8 << str << -1;
968 str = fromInvalidUtf8Sequence(utf8);
969 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-2") << utf8 << str << -1;
972 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-3") << utf8 << str << -1;
977 str = fromInvalidUtf8Sequence(utf8);
978 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-4") << utf8 << str << -1;
981 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-5") << utf8 << str << -1;
985 str = fromInvalidUtf8Sequence(utf8);
986 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-6") << utf8 << str << -1;
989 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.4-7") << utf8 << str << -1;
998 str = fromInvalidUtf8Sequence(utf8);
999 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5") << utf8 << str << -1;
1002 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-1") << 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-2") << utf8 << str << -1;
1013 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-3") << utf8 << str << -1;
1019 str = fromInvalidUtf8Sequence(utf8);
1020 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-4") << utf8 << str << -1;
1023 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-5") << utf8 << str << -1;
1028 str = fromInvalidUtf8Sequence(utf8);
1029 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-6") << utf8 << str << -1;
1032 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-7") << utf8 << str << -1;
1036 str = fromInvalidUtf8Sequence(utf8);
1037 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-8") << utf8 << str << -1;
1040 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.5-9") << 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.6") << utf8 << str << -1;
1049 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.6-1") << utf8 << str << -1;
1055 str = fromInvalidUtf8Sequence(utf8);
1056 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7") << utf8 << str << -1;
1059 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-1") << utf8 << str << -1;
1063 str = fromInvalidUtf8Sequence(utf8);
1064 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-2") << utf8 << str << -1;
1067 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.7-3") << utf8 << str << -1;
1074 str = fromInvalidUtf8Sequence(utf8);
1075 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8") << utf8 << str << -1;
1078 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-1") << utf8 << str << -1;
1083 str = fromInvalidUtf8Sequence(utf8);
1084 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-2") << utf8 << str << -1;
1087 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-3") << utf8 << str << -1;
1091 str = fromInvalidUtf8Sequence(utf8);
1092 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-4") << utf8 << str << -1;
1095 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.8-5") << 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") << utf8 << str << -1;
1107 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-1") << utf8 << str << -1;
1113 str = fromInvalidUtf8Sequence(utf8);
1114 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-2") << utf8 << str << -1;
1117 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-3") << utf8 << str << -1;
1122 str = fromInvalidUtf8Sequence(utf8);
1123 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-4") << utf8 << str << -1;
1126 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-5") << utf8 << str << -1;
1130 str = fromInvalidUtf8Sequence(utf8);
1131 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-6") << utf8 << str << -1;
1134 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.9-7") << utf8 << str << -1;
1143 str = fromInvalidUtf8Sequence(utf8);
1144 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10") << utf8 << str << -1;
1147 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-1") << 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-2") << utf8 << str << -1;
1158 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-3") << utf8 << str << -1;
1164 str = fromInvalidUtf8Sequence(utf8);
1165 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-4") << utf8 << str << -1;
1168 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-5") << utf8 << str << -1;
1173 str = fromInvalidUtf8Sequence(utf8);
1174 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-6") << utf8 << str << -1;
1177 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-7") << utf8 << str << -1;
1181 str = fromInvalidUtf8Sequence(utf8);
1182 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-8") << utf8 << str << -1;
1185 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.3.10-9") << utf8 << str << -1;
1219 str = fromInvalidUtf8Sequence(utf8);
1220 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.4") << utf8 << str << -1;
1225 str = fromInvalidUtf8Sequence(utf8);
1226 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.5.1") << utf8 << str << -1;
1231 str = fromInvalidUtf8Sequence(utf8);
1232 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.5.2") << utf8 << str << -1;
1239 str = fromInvalidUtf8Sequence(utf8);
1240 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 3.5.2-1") << utf8 << str << -1;
1246 str = QChar(QChar::ReplacementCharacter);
1247 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.1") << utf8 << str << -1;
1254 str = QChar(QChar::ReplacementCharacter);
1255 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.2") << utf8 << str << -1;
1263 str = QChar(QChar::ReplacementCharacter);
1264 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.3") << utf8 << str << -1;
1273 str = fromInvalidUtf8Sequence(utf8);
1274 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.4") << utf8 << str << -1;
1284 str = fromInvalidUtf8Sequence(utf8);
1285 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.1.5") << utf8 << str << -1;
1291 str = QChar(QChar::ReplacementCharacter);
1292 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.1") << utf8 << str << -1;
1299 str = QChar(QChar::ReplacementCharacter);
1300 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.2") << utf8 << str << -1;
1308 str = QChar(QChar::ReplacementCharacter);
1309 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.3") << utf8 << str << -1;
1318 str = fromInvalidUtf8Sequence(utf8);
1319 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.4") << utf8 << str << -1;
1329 str = fromInvalidUtf8Sequence(utf8);
1330 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.2.5") << utf8 << str << -1;
1336 str = QChar(QChar::ReplacementCharacter);
1337 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.1") << utf8 << str << -1;
1344 str = QChar(QChar::ReplacementCharacter);
1345 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.2") << utf8 << str << -1;
1353 str = QChar(QChar::ReplacementCharacter);
1354 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.3") << utf8 << str << -1;
1363 str = fromInvalidUtf8Sequence(utf8);
1364 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.4") << utf8 << str << -1;
1374 str = fromInvalidUtf8Sequence(utf8);
1375 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 4.3.5") << utf8 << str << -1;
1382 str = QChar(QChar::ReplacementCharacter);
1383 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.1") << utf8 << str << -1;
1390 str = QChar(QChar::ReplacementCharacter);
1391 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.2") << utf8 << str << -1;
1398 str = QChar(QChar::ReplacementCharacter);
1399 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.3") << utf8 << str << -1;
1406 str = QChar(QChar::ReplacementCharacter);
1407 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.4") << utf8 << str << -1;
1414 str = QChar(QChar::ReplacementCharacter);
1415 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.5") << utf8 << str << -1;
1422 str = QChar(QChar::ReplacementCharacter);
1423 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.6") << utf8 << str << -1;
1430 str = QChar(QChar::ReplacementCharacter);
1431 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.1.7") << utf8 << str << -1;
1442 str += QChar(QChar::ReplacementCharacter);
1443 str += QChar(QChar::ReplacementCharacter);
1444 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.1") << utf8 << str << -1;
1455 str += QChar(QChar::ReplacementCharacter);
1456 str += QChar(QChar::ReplacementCharacter);
1457 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.2") << utf8 << str << -1;
1468 str += QChar(QChar::ReplacementCharacter);
1469 str += QChar(QChar::ReplacementCharacter);
1470 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.3") << utf8 << str << -1;
1481 str += QChar(QChar::ReplacementCharacter);
1482 str += QChar(QChar::ReplacementCharacter);
1483 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.4") << utf8 << str << -1;
1494 str += QChar(QChar::ReplacementCharacter);
1495 str += QChar(QChar::ReplacementCharacter);
1496 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.5") << utf8 << str << -1;
1507 str += QChar(QChar::ReplacementCharacter);
1508 str += QChar(QChar::ReplacementCharacter);
1509 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.6") << utf8 << str << -1;
1520 str += QChar(QChar::ReplacementCharacter);
1521 str += QChar(QChar::ReplacementCharacter);
1522 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.7") << utf8 << str << -1;
1533 str += QChar(QChar::ReplacementCharacter);
1534 str += QChar(QChar::ReplacementCharacter);
1535 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.2.8") << utf8 << str << -1;
1542 str = QChar(QChar::ReplacementCharacter);
1543 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.3.1") << utf8 << str << -1;
1550 str = QChar(QChar::ReplacementCharacter);
1551 QTest::newRow("http://www.w3.org/2001/06/utf-8-wrong/UTF-8-test.html 5.3.2") << utf8 << str << -1;
1554 void tst_QTextCodec::utf8Codec()
1556 QTextCodec *codec = QTextCodec::codecForMib(106); // UTF-8
1557 QVERIFY(codec != 0);
1559 QFETCH(QByteArray, utf8);
1560 QFETCH(QString, res);
1563 QString str = codec->toUnicode(utf8.isNull() ? 0 : utf8.constData(),
1564 len < 0 ? qstrlen(utf8.constData()) : len);
1567 str = QString::fromUtf8(utf8.isNull() ? 0 : utf8.constData(), len);
1571 void tst_QTextCodec::utf8bom_data()
1573 QTest::addColumn<QByteArray>("data");
1574 QTest::addColumn<QString>("result");
1576 QTest::newRow("nobom")
1577 << QByteArray("\302\240", 2)
1578 << QString::fromLatin1("\240");
1581 static const ushort data[] = { 0x201d };
1582 QTest::newRow("nobom 2")
1583 << QByteArray("\342\200\235", 3)
1584 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1588 static const ushort data[] = { 0xf000 };
1589 QTest::newRow("bom1")
1590 << QByteArray("\357\200\200", 3)
1591 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1595 static const ushort data[] = { 0xfec0 };
1596 QTest::newRow("bom2")
1597 << QByteArray("\357\273\200", 3)
1598 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1602 QTest::newRow("normal-bom")
1603 << QByteArray("\357\273\277a", 4)
1608 static const ushort data[] = { 0x61, 0xfeff, 0x62 };
1609 QTest::newRow("middle-bom")
1610 << QByteArray("a\357\273\277b", 5)
1611 << QString::fromUtf16(data, sizeof(data)/sizeof(short));
1615 void tst_QTextCodec::utf8bom()
1617 QFETCH(QByteArray, data);
1618 QFETCH(QString, result);
1620 QTextCodec *const codec = QTextCodec::codecForMib(106); // UTF-8
1623 QCOMPARE(codec->toUnicode(data.constData(), data.length(), 0), result);
1625 QTextCodec::ConverterState state;
1626 QCOMPARE(codec->toUnicode(data.constData(), data.length(), &state), result);
1629 void tst_QTextCodec::utfHeaders_data()
1631 QTest::addColumn<QByteArray>("codecName");
1632 QTest::addColumn<int>("flags");
1633 QTest::addColumn<QByteArray>("encoded");
1634 QTest::addColumn<QString>("unicode");
1635 QTest::addColumn<bool>("toUnicode");
1637 QTest::newRow("utf8 bom")
1638 << QByteArray("UTF-8")
1640 << QByteArray("\xef\xbb\xbfhello")
1641 << QString::fromLatin1("hello")
1643 QTest::newRow("utf8 nobom")
1644 << QByteArray("UTF-8")
1646 << QByteArray("hello")
1647 << QString::fromLatin1("hello")
1649 QTest::newRow("utf8 bom ignore header")
1650 << QByteArray("UTF-8")
1651 << (int)QTextCodec::IgnoreHeader
1652 << QByteArray("\xef\xbb\xbfhello")
1653 << (QString(QChar(0xfeff)) + QString::fromLatin1("hello"))
1655 QTest::newRow("utf8 nobom ignore header")
1656 << QByteArray("UTF-8")
1657 << (int)QTextCodec::IgnoreHeader
1658 << QByteArray("hello")
1659 << QString::fromLatin1("hello")
1662 QTest::newRow("utf16 bom be")
1663 << QByteArray("UTF-16")
1665 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1666 << QString::fromLatin1("hel")
1668 QTest::newRow("utf16 bom le")
1669 << QByteArray("UTF-16")
1671 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1672 << QString::fromLatin1("hel")
1674 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
1675 QTest::newRow("utf16 nobom")
1676 << QByteArray("UTF-16")
1678 << QByteArray("\0h\0e\0l", 6)
1679 << QString::fromLatin1("hel")
1681 QTest::newRow("utf16 bom be ignore header")
1682 << QByteArray("UTF-16")
1683 << (int)QTextCodec::IgnoreHeader
1684 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1685 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1688 QTest::newRow("utf16 nobom")
1689 << QByteArray("UTF-16")
1691 << QByteArray("h\0e\0l\0", 6)
1692 << QString::fromLatin1("hel")
1694 QTest::newRow("utf16 bom le ignore header")
1695 << QByteArray("UTF-16")
1696 << (int)QTextCodec::IgnoreHeader
1697 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1698 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1702 QTest::newRow("utf16-be bom be")
1703 << QByteArray("UTF-16BE")
1705 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1706 << QString::fromLatin1("hel")
1708 QTest::newRow("utf16-be nobom")
1709 << QByteArray("UTF-16BE")
1711 << QByteArray("\0h\0e\0l", 6)
1712 << QString::fromLatin1("hel")
1714 QTest::newRow("utf16-be bom be ignore header")
1715 << QByteArray("UTF-16BE")
1716 << (int)QTextCodec::IgnoreHeader
1717 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1718 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1721 QTest::newRow("utf16-le bom le")
1722 << QByteArray("UTF-16LE")
1724 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1725 << QString::fromLatin1("hel")
1727 QTest::newRow("utf16-le nobom")
1728 << QByteArray("UTF-16LE")
1730 << QByteArray("h\0e\0l\0", 6)
1731 << QString::fromLatin1("hel")
1733 QTest::newRow("utf16-le bom le ignore header")
1734 << QByteArray("UTF-16LE")
1735 << (int)QTextCodec::IgnoreHeader
1736 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1737 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1741 QTest::newRow("utf32 bom be")
1742 << QByteArray("UTF-32")
1744 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1745 << QString::fromLatin1("hel")
1747 QTest::newRow("utf32 bom le")
1748 << QByteArray("UTF-32")
1750 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1751 << QString::fromLatin1("hel")
1753 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
1754 QTest::newRow("utf32 nobom")
1755 << QByteArray("UTF-32")
1757 << QByteArray("\0\0\0h\0\0\0e\0\0\0l", 12)
1758 << QString::fromLatin1("hel")
1760 QTest::newRow("utf32 bom be ignore header")
1761 << QByteArray("UTF-32")
1762 << (int)QTextCodec::IgnoreHeader
1763 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1764 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1767 QTest::newRow("utf32 nobom")
1768 << QByteArray("UTF-32")
1770 << QByteArray("h\0\0\0e\0\0\0l\0\0\0", 12)
1771 << QString::fromLatin1("hel")
1773 QTest::newRow("utf32 bom le ignore header")
1774 << QByteArray("UTF-32")
1775 << (int)QTextCodec::IgnoreHeader
1776 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1777 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1782 QTest::newRow("utf32-be bom be")
1783 << QByteArray("UTF-32BE")
1785 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1786 << QString::fromLatin1("hel")
1788 QTest::newRow("utf32-be nobom")
1789 << QByteArray("UTF-32BE")
1791 << QByteArray("\0\0\0h\0\0\0e\0\0\0l", 12)
1792 << QString::fromLatin1("hel")
1794 QTest::newRow("utf32-be bom be ignore header")
1795 << QByteArray("UTF-32BE")
1796 << (int)QTextCodec::IgnoreHeader
1797 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1798 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1802 QTest::newRow("utf32-le bom le")
1803 << QByteArray("UTF-32LE")
1805 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1806 << QString::fromLatin1("hel")
1808 QTest::newRow("utf32-le nobom")
1809 << QByteArray("UTF-32LE")
1811 << QByteArray("h\0\0\0e\0\0\0l\0\0\0", 12)
1812 << QString::fromLatin1("hel")
1814 QTest::newRow("utf32-le bom le ignore header")
1815 << QByteArray("UTF-32LE")
1816 << (int)QTextCodec::IgnoreHeader
1817 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1818 << (QString(QChar(0xfeff)) + QString::fromLatin1("hel"))
1822 void tst_QTextCodec::utfHeaders()
1824 QFETCH(QByteArray, codecName);
1825 QTextCodec *codec = QTextCodec::codecForName(codecName);
1826 QVERIFY(codec != 0);
1829 QTextCodec::ConversionFlags cFlags = QTextCodec::ConversionFlags(flags);
1830 QTextCodec::ConverterState state(cFlags);
1832 QFETCH(QByteArray, encoded);
1833 QFETCH(QString, unicode);
1835 QFETCH(bool, toUnicode);
1837 QLatin1String ignoreReverseTestOn = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? QLatin1String(" le") : QLatin1String(" be");
1838 QString rowName(QTest::currentDataTag());
1841 QString result = codec->toUnicode(encoded.constData(), encoded.length(), &state);
1842 QCOMPARE(result.length(), unicode.length());
1843 QCOMPARE(result, unicode);
1845 if (!rowName.endsWith("nobom") && !rowName.contains(ignoreReverseTestOn)) {
1846 QTextCodec::ConverterState state2(cFlags);
1847 QByteArray reencoded = codec->fromUnicode(unicode.unicode(), unicode.length(), &state2);
1848 QCOMPARE(reencoded, encoded);
1851 QByteArray result = codec->fromUnicode(unicode.unicode(), unicode.length(), &state);
1852 QCOMPARE(result, encoded);
1856 void tst_QTextCodec::codecForHtml()
1858 QByteArray html("<html><head></head><body>blah</body></html>");
1860 QCOMPARE(QTextCodec::codecForHtml(html)->mibEnum(), 4); // latin 1
1862 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 106); // UTF-8
1864 html = "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-15\" /></head></html>";
1865 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 111); // latin 15
1867 html = "<html><head><meta content=\"text/html; charset=ISO-8859-15\" http-equiv=\"content-type\" /></head></html>";
1868 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 111); // latin 15
1870 html = "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=invalid-foo\" /></head></html>";
1871 QCOMPARE(QTextCodec::codecForHtml(html, QTextCodec::codecForMib(106))->mibEnum(), 106); // UTF-8
1872 QCOMPARE(QTextCodec::codecForHtml(html)->mibEnum(), 4); // latin 1
1875 void tst_QTextCodec::codecForUtfText_data()
1877 QTest::addColumn<QByteArray>("encoded");
1878 QTest::addColumn<bool>("detected");
1879 QTest::addColumn<int>("mib");
1882 QTest::newRow("utf8 bom")
1883 << QByteArray("\xef\xbb\xbfhello")
1886 QTest::newRow("utf8 nobom")
1887 << QByteArray("hello")
1891 QTest::newRow("utf16 bom be")
1892 << QByteArray("\xfe\xff\0h\0e\0l", 8)
1895 QTest::newRow("utf16 bom le")
1896 << QByteArray("\xff\xfeh\0e\0l\0", 8)
1899 QTest::newRow("utf16 nobom")
1900 << QByteArray("\0h\0e\0l", 6)
1904 QTest::newRow("utf32 bom be")
1905 << QByteArray("\0\0\xfe\xff\0\0\0h\0\0\0e\0\0\0l", 16)
1908 QTest::newRow("utf32 bom le")
1909 << QByteArray("\xff\xfe\0\0h\0\0\0e\0\0\0l\0\0\0", 16)
1912 QTest::newRow("utf32 nobom")
1913 << QByteArray("\0\0\0h\0\0\0e\0\0\0l", 12)
1918 void tst_QTextCodec::codecForUtfText()
1920 QFETCH(QByteArray, encoded);
1921 QFETCH(bool, detected);
1924 QTextCodec *codec = QTextCodec::codecForUtfText(encoded, 0);
1926 QCOMPARE(codec->mibEnum(), mib);
1928 QVERIFY(codec == 0);
1931 #if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
1932 void tst_QTextCodec::toLocal8Bit()
1935 process.start("echo/echo");
1936 QString string(QChar(0x410));
1937 process.write((const char*)string.utf16(), string.length()*2);
1939 process.closeWriteChannel();
1940 process.waitForFinished();
1941 QCOMPARE(process.exitStatus(), QProcess::NormalExit);
1942 QCOMPARE(process.exitCode(), 0);
1946 class LoadAndConvert: public QRunnable
1949 LoadAndConvert(const QByteArray &source, QByteArray *destination)
1950 : codecName(source), target(destination)
1952 QByteArray codecName;
1956 QTextCodec *c = QTextCodec::codecForName(codecName);
1958 qWarning() << "WARNING" << codecName << "not found?";
1961 QString str = QString::fromLatin1(codecName);
1962 QByteArray b = c->fromUnicode(str);
1964 *target = codecName;
1968 class LoadAndConvertMIB: public QRunnable
1971 LoadAndConvertMIB(int mib, int *target)
1972 : mib(mib), target(target)
1978 QTextCodec *c = QTextCodec::codecForMib(mib);
1980 qWarning() << "WARNING" << mib << "not found?";
1983 QString str = QString::number(mib);
1984 QByteArray b = c->fromUnicode(str);
1991 void tst_QTextCodec::threadSafety()
1993 QList<QByteArray> codecList = QTextCodec::availableCodecs();
1994 QList<int> mibList = QTextCodec::availableMibs();
1995 QThreadPool::globalInstance()->setMaxThreadCount(12);
1997 QVector<QByteArray> res;
1998 res.resize(codecList.size());
1999 for (int i = 0; i < codecList.size(); ++i) {
2000 QThreadPool::globalInstance()->start(new LoadAndConvert(codecList.at(i), &res[i]));
2004 res2.resize(mibList.size());
2005 for (int i = 0; i < mibList.size(); ++i) {
2006 QThreadPool::globalInstance()->start(new LoadAndConvertMIB(mibList.at(i), &res2[i]));
2009 // wait for all threads to finish working
2010 QThreadPool::globalInstance()->waitForDone();
2012 QCOMPARE(res.toList(), codecList);
2013 QCOMPARE(res2.toList(), mibList);
2016 void tst_QTextCodec::invalidNames()
2018 QVERIFY(!QTextCodec::codecForName(""));
2019 QVERIFY(!QTextCodec::codecForName(QByteArray()));
2020 QVERIFY(!QTextCodec::codecForName("-"));
2021 QVERIFY(!QTextCodec::codecForName("\1a\2b\3a\4d\5c\6s\7a\xffr\xec_\x9c_"));
2022 QVERIFY(!QTextCodec::codecForName("\n"));
2023 QVERIFY(!QTextCodec::codecForName("don't exist"));
2024 QByteArray huge = "azertyuiop^$qsdfghjklm<wxcvbn,;:=1234567890�_";
2025 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2026 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2027 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2028 huge = huge + huge + huge + huge + huge + huge + huge + huge;
2029 QVERIFY(!QTextCodec::codecForName(huge));
2032 void tst_QTextCodec::checkAliases_data()
2034 QTest::addColumn<QByteArray>("codecName");
2035 QList<QByteArray> codecList = QTextCodec::availableCodecs();
2036 foreach (const QByteArray &a, codecList) {
2037 QTest::newRow( a.constData() ) << a;
2041 void tst_QTextCodec::checkAliases()
2043 QFETCH( QByteArray, codecName );
2044 QTextCodec *c = QTextCodec::codecForName(codecName);
2046 QCOMPARE(QTextCodec::codecForName(codecName), c);
2047 QCOMPARE(QTextCodec::codecForName(c->name()), c);
2049 foreach(const QByteArray &a, c->aliases()) {
2050 QCOMPARE(QTextCodec::codecForName(a), c);
2055 void tst_QTextCodec::moreToFromUnicode_data() {
2056 QTest::addColumn<QByteArray>("codecName");
2057 QTest::addColumn<QByteArray>("testData");
2059 QTest::newRow("russian") << QByteArray("ISO-8859-5")
2060 << 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");
2062 QTest::newRow("arabic") << QByteArray("ISO-8859-6")
2063 << 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");
2065 QTest::newRow("greek") << QByteArray("ISO-8859-7")
2066 << 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");
2068 QTest::newRow("turkish") << QByteArray("ISO-8859-9")
2069 << 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");
2071 QTest::newRow("latin1") << QByteArray("ISO-8859-1")
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 QByteArray sms7bit_ba;
2075 for (int i=1; i <= 0x7f; ++i) {
2077 sms7bit_ba.append(i);
2081 QTest::newRow("latin2") << QByteArray("ISO-8859-2")
2082 << 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");
2084 QTest::newRow("latin3") << QByteArray("ISO-8859-3")
2085 << 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");
2087 QTest::newRow("latin4") << QByteArray("ISO-8859-4")
2088 << 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");
2090 QTest::newRow("russian 2") << QByteArray("ISO-8859-5")
2091 << 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");
2093 QTest::newRow("arabic 2") << QByteArray("ISO-8859-6")
2094 << 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");
2096 QTest::newRow("greek 2") << QByteArray("ISO-8859-7")
2097 << 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");
2099 QTest::newRow("latin5") << QByteArray("ISO-8859-9")
2100 << 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");
2102 QTest::newRow("latin6") << QByteArray("ISO-8859-10")
2103 << 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");
2106 QByteArray iso8859_11_ba;
2107 for (int x=0x20; x<=0x7f; ++x) {
2108 iso8859_11_ba.append(x);
2110 for (int x=0xa0; x<0xff; ++x) {
2111 if ((x>=0xdb && x<0xdf) || x>0xfb){
2114 iso8859_11_ba.append(x);
2116 QTest::newRow("latin-thai") << QByteArray("ISO-8859-11") << iso8859_11_ba;
2119 QTest::newRow("latin7") << QByteArray("ISO-8859-13")
2120 << 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");
2122 QTest::newRow("celtic") << QByteArray("ISO-8859-14")
2123 << 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");
2125 QTest::newRow("latin9") << QByteArray("ISO-8859-15")
2126 << 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");
2128 // QTest::newRow("latin10") << QByteArray("ISO-8859-16")
2129 // << 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");
2131 QTest::newRow("cp850") << QByteArray("CP850")
2132 << 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");
2134 QTest::newRow("cp874") << QByteArray("CP874")
2135 << 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");
2137 QTest::newRow("cp1250") << QByteArray("CP1250")
2138 << 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");
2140 QTest::newRow("cp1251") << QByteArray("CP1251")
2141 << 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");
2143 QTest::newRow("cp1252") << QByteArray("CP1252")
2144 << 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");
2146 QTest::newRow("cp1253") << QByteArray("CP1253")
2147 << 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");
2149 QTest::newRow("cp1254") << QByteArray("CP1254")
2150 << 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");
2152 QTest::newRow("cp1255") << QByteArray("CP1255")
2153 << 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");
2155 QTest::newRow("cp1256") << QByteArray("CP1256")
2156 << 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");
2158 QTest::newRow("cp1257") << QByteArray("CP1257")
2159 << 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");
2161 QTest::newRow("cp1258") << QByteArray("CP1258")
2162 << 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");
2164 QByteArray koi8_r_ba;
2165 for (int x=0x20; x<=0xff; ++x) {
2166 if (x!=0x9A && x!=0xbf) {
2167 koi8_r_ba.append(x);
2170 QTest::newRow("KOI8-R") << QByteArray("KOI8-R") << koi8_r_ba;
2172 QByteArray koi8_u_ba;
2173 for (int x=0x20; x<=0xff; ++x) {
2174 koi8_u_ba.append(x);
2176 QTest::newRow("KOI8-U") << QByteArray("KOI8-U") << koi8_u_ba;
2180 for (unsigned char u=0xa1; u<=0xf9; u++) {
2184 for (unsigned char v=0x40; v<=0x7e; v++) {
2190 case 0xa2: v_up=0xa1; break;
2191 case 0xa3: v_up=0xbf; break;
2192 case 0xc7: v_up=0xfc; break;
2193 case 0xf9: v_up=0xd5; break;
2197 for (unsigned char v=0xa1; v<=v_up; v++) {
2198 if (u==0xa2 && (v==0xcc || v==0xce)) {
2206 QTest::newRow("BIG5") << QByteArray("BIG5") << big5_ba;
2208 QByteArray gb2312_ba;
2209 for (unsigned char u=0xa1; u<=0xf7; u++) {
2210 for (unsigned char v=0xa1; v<=0xfe; v++) {
2211 gb2312_ba.append(u);
2212 gb2312_ba.append(v);
2216 QTest::newRow("GB2312") << QByteArray("GB2312") << gb2312_ba;
2219 void tst_QTextCodec::moreToFromUnicode()
2221 QFETCH( QByteArray, codecName );
2222 QFETCH( QByteArray, testData );
2224 QTextCodec *c = QTextCodec::codecForName( codecName.data() );
2227 QString uStr = c->toUnicode(testData);
2228 QByteArray cStr = c->fromUnicode(uStr);
2229 QCOMPARE(testData, cStr);
2232 void tst_QTextCodec::shiftJis()
2234 QByteArray backslashTilde("\\~");
2235 QTextCodec* codec = QTextCodec::codecForName("shift_jis");
2236 QString string = codec->toUnicode(backslashTilde);
2237 QCOMPARE(string.length(), 2);
2238 QCOMPARE(string.at(0), QChar(QLatin1Char('\\')));
2239 QCOMPARE(string.at(1), QChar(QLatin1Char('~')));
2241 QByteArray encoded = codec->fromUnicode(string);
2242 QCOMPARE(encoded, backslashTilde);
2245 struct DontCrashAtExit {
2246 ~DontCrashAtExit() {
2247 QTextCodec *c = QTextCodec::codecForName("utf8");
2249 c->toUnicode("azerty");
2255 QTEST_MAIN(tst_QTextCodec)
2256 #include "tst_qtextcodec.moc"