开发者

iphone sqlite3_column_text issue

开发者 https://www.devze.com 2022-12-23 04:36 出处:网络
I have a column in sqlite3 table. Column has valu开发者_开发百科es like 1 ½” 1 ¾” 2 ½” etc.

I have a column in sqlite3 table. Column has valu开发者_开发百科es 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.


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];
0

精彩评论

暂无评论...
验证码 换一张
取 消