Lee Armstrong
Lee Armstrong

Reputation: 11450

Need unicode characters in UITableView from SQLite database

I have some NSString varibales that incude items like Ð and Õ and if I do

cell.textLabel.text = person.name;

and if it contains one of those characters the cell.textlabel is blank!

I have discovered that if I use

NSString *col1 = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];

To pull my data back it pulls back null, however using the deprectared method

NSString *col1 = [NSString stringWithCString:(char *)sqlite3_column_text(compiledStatement, 0)];

Shows the characters!

Any ideas?

Upvotes: 0

Views: 1029

Answers (2)

Lee Armstrong
Lee Armstrong

Reputation: 11450

Actually played around and got the answer!

NSString *col1 = [NSString stringWithCString:(char *)sqlite3_column_text(compiledStatement, 0) encoding:NSASCIIStringEncoding];

Upvotes: 1

Robert maefs
Robert maefs

Reputation: 44

Iirc, char is a cstring, in the first sql ex you're putting UTF8 multibyte characters into single byte c string so that will be bad, null, or unpredictable.

As for putting UTF8 into a label, it can def be done since there are Asian language apps. Maybe there's a tutorial for that you can look up.

Upvotes: 0

Related Questions