NSString 声明
我在我的应用程序中使用 SQLite 数据库,我需要从表(UTF8 Cyrilic)获取数据。我已经尝试过这个
NSString *aName = [NSString stringWithFormat:@"%s",(char *)sqlite3_column_text(compiledStatement, 1)];
和
NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
这个这两种方法。第一个从表中获取数据,但编码错误。第二个没有给我任何结果,控制台显示
*** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“*** ?>” [NSString stringWithUTF8String:]: NULL cString'
我应该在哪里搜索问题以及如何正确使用编码?
I'm using SQLite database in my application and i need to get data from table (UTF8 Cyrilic). I've tried 2 methods this
NSString *aName = [NSString stringWithFormat:@"%s",(char *)sqlite3_column_text(compiledStatement, 1)];
and
NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
this. The first one gets data from the table but with wrong encoding. The second one doesn't give me any result and console shows
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** ?> [NSString stringWithUTF8String:]: NULL cString'
Where I should search problem and how to work right with encodings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
并确保您通过相同的方法存储日期:
Try
And sure that you store date by the same method: