diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-09-01 14:26:51 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2014-10-29 08:58:31 +0100 |
commit | 38c2e3d1049f494529cb9876bcd564ec20ba512c (patch) | |
tree | daac8ed0a17d8c2b38ea20006cb48647ff75d98a /src/corelib/io/qsettings.cpp | |
parent | ad1ec8b57dde6f5cbb7a4f66272794a067dc3917 (diff) |
Properly detect UTF-8 BOM markers in ini files
If we detect a utf8 BOM mark at the beginning of the .ini
file, skip the marker and set the iniCodec to utf8.
Task-number: QTBUG-23381
Change-Id: I1b37fc4f1638a48e4f3ee71ab165e2989bc592f1
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'src/corelib/io/qsettings.cpp')
-rw-r--r-- | src/corelib/io/qsettings.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index d896da176a..ebca7d57ff 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1637,6 +1637,15 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, int sectionPosition = 0; bool ok = true; +#ifndef QT_NO_TEXTCODEC + // detect utf8 BOM + const uchar *dd = (const uchar *)data.constData(); + if (data.size() >= 3 && dd[0] == 0xef && dd[1] == 0xbb && dd[2] == 0xbf) { + iniCodec = QTextCodec::codecForName("UTF-8"); + dataPos = 3; + } +#endif + while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) { char ch = data.at(lineStart); if (ch == '[') { |