mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-09 05:19:55 -05:00
Fix wrong BOM detection
This fixes a bug introduced in 27c657902e.
In that commit we are checking if a string starts with a Unicode BOM and
remove the BOM if necessary. Apparently though Qt's startsWith()
function doesn't work as exected here, so it's changed to a manual
comparison in this commit which seems to work fine.
The first person who can explain that behaviour to me gets a free beer
if we meet in person.
See issue #1279.
See issue #1282.
This commit is contained in:
+3
-3
@@ -34,16 +34,16 @@ bool startsWithBom(const QByteArray& data)
|
||||
|
||||
QByteArray removeBom(QByteArray& data)
|
||||
{
|
||||
if(data.startsWith("\xEF\xBB\xBF"))
|
||||
if(data.left(3) == QByteArray("\xEF\xBB\xBF"))
|
||||
{
|
||||
QByteArray bom = data.left(3);
|
||||
data.remove(0, 3);
|
||||
return bom;
|
||||
} else if(data.startsWith("\xFE\xFF") || data.startsWith("\xFF\xFE")) {
|
||||
} else if(data.left(2) == QByteArray("\xFE\xFF") || data.left(2) == QByteArray("\xFF\xFE")) {
|
||||
QByteArray bom = data.left(2);
|
||||
data.remove(0, 2);
|
||||
return bom;
|
||||
} else if(data.startsWith("\x00\x00\xFE\xFF") || data.startsWith("\xFF\xFE\x00\x00")) {
|
||||
} else if(data.left(4) == QByteArray("\x00\x00\xFE\xFF") || data.left(4) == QByteArray("\xFF\xFE\x00\x00")) {
|
||||
QByteArray bom = data.left(4);
|
||||
data.remove(0, 4);
|
||||
return bom;
|
||||
|
||||
Reference in New Issue
Block a user