Skip to content

Commit afb2c43

Browse files
committed
Use the preprocessor macro instead of the magic number for the encoding
value
1 parent 25bac8d commit afb2c43

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/sqlitedb.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,15 @@ bool DBBrowserDB::open(const QString& db, bool readOnly)
209209

210210
const char* encodingBytes = header.constData() + 56;
211211
// The variable 'encoding' will have one of the following values:
212-
// 1: UTF-8, 2: UTF-16LE, 3: UTF-16BE
212+
// SQLITE_UTF8, SQLITE_UTF16LE, SQLITE_UTF16BE (https://www.sqlite.org/fileformat.html#text_encoding)
213213
quint32 encoding = ((quint8)encodingBytes[0] << 24) |
214214
((quint8)encodingBytes[1] << 16) |
215215
((quint8)encodingBytes[2] << 8) |
216216
((quint8)encodingBytes[3]);
217217

218218
// Open database file
219219
int status=0;
220-
if(encoding == 1)
220+
if(encoding == SQLITE_UTF8)
221221
{
222222
status = sqlite3_open_v2(
223223
db.toUtf8(),

0 commit comments

Comments
 (0)