mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Fix default collation for UTF16 strings
Fix our default collation which we install when an unknown collation is requested to (more or less) support UTF16 strings as well. Before this UTF16 strings wouldn't compare correctly because they might contain null bytes which would lead to only the first (few) byte(s) getting compared. See issue #1172.
This commit is contained in:
@@ -29,11 +29,8 @@ template <typename Ret, typename... Params>
|
||||
std::function<Ret(Params...)> Callback<Ret(Params...)>::func;
|
||||
|
||||
// collation callbacks
|
||||
int collCompare(void* /*pArg*/, int /*eTextRepA*/, const void* sA, int /*eTextRepB*/, const void* sB)
|
||||
int collCompare(void* /*pArg*/, int sizeA, const void* sA, int sizeB, const void* sB)
|
||||
{
|
||||
size_t sizeA = strlen((const char*)sA);
|
||||
size_t sizeB = strlen((const char*)sB);
|
||||
|
||||
if(sizeA == sizeB)
|
||||
return memcmp(sA, sB, sizeA);
|
||||
return sizeA - sizeB;
|
||||
|
||||
@@ -19,7 +19,7 @@ enum
|
||||
typedef QMultiMap<QString, sqlb::ObjectPtr> objectMap; // Maps from object type (table, index, view, trigger) to a pointer to the object representation
|
||||
typedef QMap<QString, objectMap> schemaMap; // Maps from the schema name (main, temp, attached schemas) to the object map for that schema
|
||||
|
||||
int collCompare(void* pArg, int eTextRepA, const void* sA, int eTextRepB, const void* sB);
|
||||
int collCompare(void* pArg, int sizeA, const void* sA, int sizeB, const void* sB);
|
||||
|
||||
class DBBrowserDB : public QObject
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user