QSettings: Read past UTF-8 BOM even without textcodec support
Try to read past an UTF-8 BOM even if no textcodec support is available, but do set the status to FormatError then. This is in line with the general 'best effort' approach in QSettings. It also allows qmake (that is built without textcodec support) to gracefully load qt.conf files with a UTF-8 BOM, though non-Latin1 characters might still be misrepresented. Fixes: QTBUG-83456 Change-Id: I31b45dc5a8adf7950910897a2b33ae16990d3818 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
e7eff98401
commit
9ba09e26d7
@ -1673,14 +1673,16 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data,
|
||||
int sectionPosition = 0;
|
||||
bool ok = true;
|
||||
|
||||
#if QT_CONFIG(textcodec)
|
||||
// detect utf8 BOM
|
||||
const uchar *dd = (const uchar *)data.constData();
|
||||
if (data.size() >= 3 && dd[0] == 0xef && dd[1] == 0xbb && dd[2] == 0xbf) {
|
||||
#if QT_CONFIG(textcodec)
|
||||
iniCodec = QTextCodec::codecForName("UTF-8");
|
||||
#else
|
||||
ok = false;
|
||||
#endif
|
||||
dataPos = 3;
|
||||
}
|
||||
#endif
|
||||
|
||||
while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) {
|
||||
char ch = data.at(lineStart);
|
||||
|
Loading…
Reference in New Issue
Block a user