mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 19:11:39 -06:00
Detect some Unicode BOMs and always treat data starting with a BOM as text. We might need to fine-tune this later but it should be an improvement already. In the Edit Dialog remove the BOM from the text editor but keep it in the hex editor. Also add it back to the text when saving changes in text mode. This way the BOM is out of the way for text edits but is not lost either when editing a cell.
21 lines
1.0 KiB
C
21 lines
1.0 KiB
C
#ifndef DATA_H
|
|
#define DATA_H
|
|
|
|
#include <QString>
|
|
|
|
// This returns false if the data in the data parameter contains binary data. If it is text only, the function returns
|
|
// true. If the second parameter is specified, it will be used to convert the data from the given encoding to Unicode
|
|
// before doing the check. The third parameter can be used to only check the first couple of bytes which speeds up the
|
|
// text but makes it less reliable
|
|
bool isTextOnly(QByteArray data, const QString& encoding = QString(), bool quickTest = false);
|
|
|
|
// This function returns true if the data in the data parameter starts with a Unicode BOM. Otherwise it returns false.
|
|
bool startsWithBom(const QByteArray& data);
|
|
|
|
// This function checks if the data in the data parameter starts with a Unicode BOM. If so, the BOM is removed from the
|
|
// byte array and passed back to the caller separately as the return value of the function. If the data does not start
|
|
// with a BOM an empty byte array is returned and the original data is not modified.
|
|
QByteArray removeBom(QByteArray& data);
|
|
|
|
#endif
|