SQLite/iPhone read copyright symbol
Posted
by Marco A
on Stack Overflow
See other posts from Stack Overflow
or by Marco A
Published on 2010-06-14T04:56:31Z
Indexed on
2010/06/14
5:02 UTC
Read the original article
Hit count: 230
Hi All, I am having problems reading the copyright symbol from a sqlite db that I have for my App that I am developing. I import the information manually, ie, from an excel sheet. I have tried two ways of doing it and failed with both: 1) Tried replacing the copyright symbol with "\u00ae" (unicode combination) within excel and then importing the modified file. - Result: I get the combination of \u00ae as a part of the string, it doesnt detect the unicode combination. 2) Tried leaving as it is. Importing the excel with the copyright symbol. - Result: I get a symbol that is different from the copyright, its something like an AE put together.looks like this: Æ
Heres my code how I read from DB:
-(void) readCategoriesFromDatabase:(NSString *) rest_input {
// Init the products Array
categories = [[NSMutableArray alloc] init];
// Open the database from the users filessytem
rest_input = [rest_input stringByAppendingString:@"'"];
NSString *newString;
newString = [@"select distinct category from food where restaurant='" stringByAppendingString:rest_input];
const char *cat_sqlStatement = [newString UTF8String];
sqlite3_stmt *cat_compiledStatement;
if(sqlite3_prepare_v2(database, cat_sqlStatement, -1, &cat_compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
while(sqlite3_step(cat_compiledStatement) == SQLITE_ROW) {
NSString *catName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(cat_compiledStatement,0)];
// Create a new product object with the data from the database
Product *category = [[Product alloc] initWithName:catName];
// Add the product object to the respective Array
[categories addObject:category];
[category release];
}
sqlite3_finalize(cat_compiledStatement);
}
NSLog(@"Finished Accessing Database to gather Categories...."); }
I open the DB with this function:
-(void) checkAndCreateDatabase{
NSLog(@"Checking/Creating Database....");
NSFileManager *fileManager = [NSFileManager defaultManager];
success = [fileManager fileExistsAtPath:databasePath];
[fileManager removeFileAtPath:databasePath handler:nil];
NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];
[fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:nil];
[fileManager release];
if (sqlite3_open([databasePath UTF8String], &database) != SQLITE_OK) {
sqlite3_close(database);
database = nil;
}
NSLog(@"Finished Checking/Creating Database....");
}
Thanks to anything that can help me out.
© Stack Overflow or respective owner