diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-04-23 11:18:17 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-04-24 10:47:49 +0200 |
commit | f56ef579ba5b1d3adda060fa9c0707e37f9f1baa (patch) | |
tree | 59128b7dca8086510bde7e6912ba2a7532361ccb /tests | |
parent | cae970c68663c320bcce86160d44d857bfc68fd0 (diff) |
Restore handling of BOMs in QString::fromUtf8
8dd47e34b9b96ac27a99cdcf10b8aec506882fc2 removed the handling of the
BOMs but did not document it. This brings the behavior back and adds a
unit test so we don't break it again.
Discussed-on: http://lists.qt-project.org/pipermail/development/2014-April/016532.html
Change-Id: Ifb7a9a6e5a494622f46b8ab435e1d168b862d952
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/tools/qstring/tst_qstring.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index d9d6b985b7..95d377b176 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -3619,6 +3619,14 @@ void tst_QString::fromUtf8_data() str += " some "; QTest::newRow("str3-len") << QByteArray("\342\202\254 some text") << str << 9; + // test that QString::fromUtf8 suppresses an initial BOM, but not a ZWNBSP + str = "hello"; + QByteArray bom("\357\273\277"); + QTest::newRow("bom0") << bom << QString() << 3; + QTest::newRow("bom1") << bom + "hello" << str << -1; + QTest::newRow("bom+zwnbsp0") << bom + bom << QString(QChar(0xfeff)) << -1; + QTest::newRow("bom+zwnbsp1") << bom + "hello" + bom << str + QChar(0xfeff) << -1; + str = "hello"; str += QChar::ReplacementCharacter; str += QChar(0x68); |