jeudi 8 janvier 2015

iOS: SQLite Russian letters turn into strange symbols

I am inserting Russian words into SQLite DB and inside the database (using some DBMS software) they are looking good. But when I retrieve them, the look like this: —É–ª. –°–∞–º–æ–≥–æ –∫—Ä—É—Ç–æ–≥–æ —á—É–≤–∞–∫–∞.


Insert code:



NSString *sql = @"INSERT INTO (. . .) "
" VALUES (. . . )";
sqlite3_stmt *insert;
int result = sqlite3_prepare_v2(self.db, [sql UTF8String], -1, &insert, NULL);
if (result == SQLITE_OK) {
sqlite3_bind_text(insert, 1, [favouriteAction.nameAction UTF8String], -1, SQLITE_TRANSIENT);


. . .


Select code:



NSString *sql = nil;
sql = [NSString stringWithFormat:@"SELECT * FROM UserFavourites"];
sqlite3_stmt *select;

int result = sqlite3_prepare_v2(self.db, [sql UTF8String], -1, &select, NULL);

NSMutableArray* userFavourites = [[NSMutableArray alloc]initWithCapacity:20];
NSLog(@"SQLITE_OK %d", result);
if (result == SQLITE_OK) {

// sqlite3_bind_int(select, 1, (int)user_id);

while (sqlite3_step(select) == SQLITE_ROW) {
NSMutableArray *values = [[NSMutableArray alloc] initWithCapacity:8];
ActionCreation* ac = [[ActionCreation alloc]init];
// get the nameAction:
[values addObject:
[NSString stringWithFormat:@"%s", sqlite3_column_text(select, 0)]];


How to fix this problem? Thank you.


Aucun commentaire:

Enregistrer un commentaire