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

Ensure that TEXT column is UTF-8 encoded before using sqlite3_column_blob() #387

Merged
merged 1 commit into from
Dec 11, 2022

Conversation

SRombauts
Copy link
Owner

If the database is in a different format (ie. UTF-16) the memory that sqlite3_column_blob() will point to by default will be the native (UTF-16) encoding. Calling sqlite3_column_bytes() will basically be a noop for a BLOB or a TEXT already in UTF-8. Otherwise it'll convert to TEXT w/UTF-8.

Run the 'basis' tests against both a UTF-8 and a UTF-16 database. Reset & rerun query between tests blocks to reset column types. Reorder a few getText()/getString() operations to ensure we test both ordering. Don't try to convert random blob to TEXT. Will fail encoding conversion.

Extracted from #379 by @dougnazar

…blob()

If the database is in a different format (ie. UTF-16) the memory that
sqlite3_column_blob() will point to by default will be the native (UTF-16)
encoding. Calling sqlite3_column_bytes() will basically be a noop for
a BLOB or a TEXT already in UTF-8. Otherwise it'll convert to TEXT w/UTF-8.

Run the 'basis' tests against both a UTF-8 and a UTF-16 database.
Reset & rerun query between tests blocks to reset column types.
Reorder a few getText()/getString() operations to ensure we test both ordering.
Don't try to convert random blob to TEXT. Will fail encoding conversion.
@SRombauts SRombauts added the bug label Dec 11, 2022
@SRombauts SRombauts self-assigned this Dec 11, 2022
@SRombauts SRombauts merged commit c195cfe into master Dec 11, 2022
@SRombauts SRombauts deleted the fix-column-get-string-utf16 branch December 11, 2022 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants