Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix utf8 issue #2

Closed
wants to merge 3 commits into from
Closed

Conversation

spacepope
Copy link

Hi Chris,

i found the cause of #1.

As sqlite3_column_text() returns an unsigned char*, checking each byte as signed int could result in misinterpreted bitmask and therefore malformatted unicode signs.
Getting each byte into an unsigned char instead of an int seems to fix this issue. 🎉

Can you please confirm this and merge the fix or the fixed libraries also in your https://github.com/litehelpers/Cordova-sqlite-evcore-extbuild-free repository?

(i had to modify the jni/*.mk files to be able to successfully compile and use this library under Windows 10 bash. Not sure if you need this, but i included it in the PR anyway..)

Thanks and best regards,

Hannes

As sqlite3_column_text() returns an unsigned char*, checking each byte as signed int could result in incorrect bitmask and therefore malformatted unicode signs.
Getting each byte into an unsigned char instead of an int seems to fix this issue.
…tbuild-free, the matching SQLite build flags have to be added.
@spacepope
Copy link
Author

Also as a sidenote to this:

cutting out all chars below 32 could be problematic too sometimes (look at } else if (pc >= 32 && pc < 127) {).

One should be able to get the complete UTF-8 string out of SQLite as it is stored, regardless of code entry point values in it..
(perhaps something like decribed at http://shakddoo.github.io/ndk-unicode-utf8/ ?)

@brodybits
Copy link
Collaborator

brodybits commented Jan 17, 2018

Thanks for the contribution, please accept my apologies for the delay in integrating this one as well as storesafe/cordova-sqlite-storage#709.

I just saw the issue in case of 2-octet and 3-octet UTF-8 characters on Android x86_64 emulator, hoping to make this fix in the near future for which you will absolutely get credit.

cutting out all chars below 32 could be problematic too sometimes (look at } else if (pc >= 32 && pc < 127) {).

Sounds right, will test further to be absolutely sure.

P.S. Also reproduced on x86 (32-bit) emulator

@spacepope
Copy link
Author

Nice!
If something can be reproduced, it can be fixed/enhanced... 👍
Definitely looking forward to see this getting more "bullet proof" 😃

brodybits pushed a commit that referenced this pull request Apr 5, 2018
(unwanted sign extension in conversion)

THANKS to @spacepope (Hannes Petersen <jhpetersen@gmx.de>)
for pointing this one out.

Closes #2

Fixes #1
(marked as duplicate)

(Also reported in storesafe/cordova-sqlite-evcore-extbuild-free#19)
brodybits pushed a commit that referenced this pull request Apr 6, 2018
(unwanted sign extension in conversion)

THANKS to @spacepope (Hannes Petersen <jhpetersen@gmx.de>)
for pointing this one out.

- #2
- fixes #1
  (marked as duplicate)
- storesafe/cordova-sqlite-evcore-extbuild-free#19
brodybits pushed a commit that referenced this pull request Apr 6, 2018
also using sqlite3_column_bytes to avoid possible trunction issue

address sidenote by @spacepope (Hannes Petersen <jhpetersen@gmx.de>)
about character values below 32 (U+0020) in
#2
brodybits pushed a commit that referenced this pull request Apr 11, 2018
also using sqlite3_column_bytes to avoid possible trunction issue

address sidenote by @spacepope (Hannes Petersen <jhpetersen@gmx.de>)
about character values below 32 (U+0020) in
#2
brodybits pushed a commit to brodybits/cordova-sqlite-evcore-free-dependencies that referenced this pull request Apr 11, 2018
brodybits pushed a commit to cbforks/cordova-sqlite-evcore-legacy-ext-common-free-dev that referenced this pull request Apr 11, 2018
brodybits pushed a commit to storesafe/cordova-sqlite-evcore-extbuild-free that referenced this pull request Apr 12, 2018
(cordova-sqlite-evcore-extbuild-free 0.9.7-pre1)

in included evcore-native-driver.jar for Android

ref:
- #19
- storesafe/android-sqlite-evcore-ndk-driver-free#1
- storesafe/android-sqlite-evcore-ndk-driver-free#2
brodybits pushed a commit to storesafe/cordova-plugin-sqlite-evplus-ext-common-free that referenced this pull request Apr 12, 2018
@brodybits
Copy link
Collaborator

The issue you reported in #1 is now resolved, solution is very similar to what @spacepope proposed here to resolve a conversion warning (a second, similar warning was also resolved for x86 & x86_64).

The issue with character values below 32 will be handled in storesafe/cordova-sqlite-evcore-extbuild-free#28, should be resolved in the near future.

My apologies to anyone who may have been affected by the delay.

@brodybits brodybits closed this Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants