views:

268

answers:

1

I have a column in sqlite3 table. Column has values like

1 ½”

1 ¾”

2 ½” etc. Column has VARCHAR datatype.

I am using this code.

pref_HoseDiameter = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]; 

Now, when I am fetching these values from database, I am getting pref_HoseDiameter string values like this:

1 1/2"

1 3/4"

2 1/2"

How to fetch those values as they are in database or how to convert them that look like database values.

Help would be appreciated. Thanks in advance.

+1  A: 

Try to use sqlite3_column_text16 to get the string as UTF-16, then create the string with +stringWithCharacters:.

const UInt16* text = sqlite3_column_text16(statement, column);
int text_len = // find the first 0x0000 in text;
NSString* str = [NSString stringWithCharacters:text length:text_len];
KennyTM
can you give me the exact syntax?
Ruchir Shah