Skip to content

ExecuteQuery - Non-UTF8 Characters #18

@jruston

Description

@jruston

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions