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

ExecuteQuery - Non-UTF8 Characters #18

Open
jruston opened this issue Apr 30, 2015 · 0 comments
Open

ExecuteQuery - Non-UTF8 Characters #18

jruston opened this issue Apr 30, 2015 · 0 comments

Comments

@jruston
Copy link

jruston commented Apr 30, 2015

Hi,

I've just seen some crash logs in my app from this code:

} else if (sqlite3_column_text(statement,x) != NULL) {
[data addObject:@((char*)sqlite3_column_text(statement,x))];
}

Putting non-UTF8 characters into it seems to crash it (or at least it did when trying to display some Swedish text). I managed to fix it using this:

NSString *s = [NSString stringWithCString:(char *)sqlite3_column_text(statement,x) encoding:NSUTF8StringEncoding];
if (s == nil) {
s = [NSString stringWithCString:(char *)sqlite3_column_text(statement,x) encoding:NSASCIIStringEncoding];
}
[data addObject:s];

Not ideal, but it works for now. Might be worth looking into this though.

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

No branches or pull requests

1 participant