I have a file with contents something like this:
INSERT INTO table VALUES (NULL,'° F','Degrees Fahrenheit');
INSERT INTO table VALUES (NULL,'° C','Degrees Celsius');
Now, to parse this, I have something like this:
NSString *sql = [NSString stringWithContentsOfFile:filename];
Printing this string to the console looks correct. Then, I want to make an actual insert statement out of it:
const char *sqlString = [query UTF8String];
const char *endOfString;
if (sqlite3_prepare_v2(db, sqlString + nextStatementStart, -1, &stmt, &endOfString) != SQLITE_OK) {
return NO;
}
At this point, checking the query still returns the correct result. That is, sqlite_sql(stmt)
returns INSERT INTO table VALUES (NULL,'° F','Degrees Fahrenheit');
So then I run it with sqlite3_step(stmt);
At this point, viewing the database reveals this:
1|° F|Degrees Fahrenheit
I'm not using any _16 functions anywhere (like sqlite_open16
).
Where is the encoding issue? How do I fix this?