From b52ef3c1059636bffcf2c4ec2a96df6391259c6f Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Thu, 5 Apr 2018 19:21:39 -0400 Subject: [PATCH] Resolve issue with multi-byte UTF-8 characters (unwanted sign extension in conversion) THANKS to @spacepope (Hannes Petersen ) for pointing this one out. - litehelpers/Android-sqlite-evcore-native-driver-free#2 - fixes litehelpers/Android-sqlite-evcore-native-driver-free#1 (marked as duplicate) - litehelpers/Cordova-sqlite-evcore-extbuild-free#19 --- native/sqlc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/native/sqlc.c b/native/sqlc.c index c2c37bf..d222311 100644 --- a/native/sqlc.c +++ b/native/sqlc.c @@ -471,7 +471,13 @@ const char *sqlc_evcore_qc_execute(sqlc_handle_t qc, const char * batch_json, in rrlen += 1; while (pi < pplen) { - int pc = pptext[pi]; + // Use uint8_t (unsigned char) to avoid unwanted conversion + // with sign extension: + // sqlite3_column_text() returns pointer to unsigned char + // (same thing as pointer to uint8_t) + // THANKS to @spacepope (Hannes Petersen) for + // pointing this one out. + const uint8_t pc = pptext[pi]; if (pc == '\\') { rr[rrlen++] = '\\';