gpt4 book ai didi

ios - 在sqlite中以unicode形式获取普通文本

转载 作者:行者123 更新时间:2023-11-29 12:08:04 25 4
gpt4 key购买 nike

我在我的 iOS 项目中使用 sqlite 数据库。我已经准备好数据库,我在其中获取英文文本、旁遮普文本、印地文文本和英文翻译。我正在使用此代码从数据库中获取数据:

    NSMutableArray *getData = [[NSMutableArray alloc]init];
getData = [[DBManager sharedDatabase]tableBani:[NSString stringWithFormat:@"select *from TableBani"]];
NSLog(@"getData..%@",getData);


but in result I am getting this from data base:

getData..(
{
EnglishText = "Ik\U201a\U00f1\U00b4oa\U2248\U00e2k\U0192\U00c5r sa\U00b7\U03c0\U00d8 n\U0192\U00c5m kar\U00b7\U03c0\U00d8\U0192\U00c5 purak\U00b7\U222b\U00f1 nirb\U00b7\U222b\U00f1a\U201a\U00f1\U00b4o nirvair ak\U0192\U00c5l m\U2248\U00b4ra\U00b7\U03c0\U00d8 aj\U2248\U00b4n\U0192\U00b4 saib\U00b7\U222b\U00f1a\U2248\U00e2 gur pars\U0192\U00c5\U00b7\U220f\U00e8.";
EnglishTranslation = "One Universal Creator God. The Name Is Truth. Creative Being Personified. No Fear. No Hatred. Image Of The Undying, Beyond Birth, Self-Existent. By Guru's Grace ~";
HindiText = "\U2021\U00a9\U00a5 \U2021\U00a7\U220f\U2021\U00a7\U00a7\U2021\U00a7\U00f8 \U2021\U00a7\U00ae\U2021\U00a7\U00e6\U2021\U00a7\U00c6\U2021\U2022\U00c5 \U2021\U00a7\U00ef\U2021\U00a7\U221e\U2021\U00a7\U00a7\U2021\U00a7\U00e6 \U2021\U00a7\U2122\U2021\U2022\U00c5\U2021\U00a7\U221e\U2021\U00a7\U00f1\U2021\U2022\U00c5 \U2021\U00a7\U00ae\U2021\U00a7\U00f8\U2021\U00a7\U221e\U2021\U00a7\U2260\U2021\U00a7\U00e2 \U2021\U00a7\U00ae\U2021\U00a7\U00f8\U2021\U00a7\U221e\U2021\U00a7\U00b5\U2021\U2022\U00e0\U2021\U00a7\U221e\U2021\U2022\U00c5 \U2021\U00a7\U00d6\U2021\U00a7\U00ef\U2021\U00a7\U00e6\U2021\U00a7\U2264 \U2021\U00a7\U00c6\U2021\U2022\U00c7\U2021\U00a7\U221e\U2021\U00a7\U00a7\U2021\U00a7\U00f8 \U2021\U00a7\U00d6\U2021\U00a7\U00fa\U2021\U2022\U00c7\U2021\U00a7\U00ae\U2021\U2022\U00c4 \U2021\U00a7\U220f\U2021\U2022\U00e0\U2021\U00a7\U2260\U2021\U00a7\U00c7 \U2021\U00a7\U00f3\U2021\U2022\U00c5\U2021\U00a7\U221e \U2021\U00a7\U2122\U2021\U2022\U00e7\U2021\U00a7\U221e\U2021\U00a7\U220f\U2021\U00a7\U00e6\U2021\U00a7\U00b6\U2021\U00a7\U00f8 \U2021\U2022\U2022";
ID = 1;
PunjabiText = "\U2021\U00a9\U00a5 \U2021\U00ae\U220f\U2021\U00ae\U00a7\U2021\U00ae\U00f8 \U2021\U00ae\U00ae\U2021\U00ae\U00e6\U2021\U00ae\U00c6\U2021\U00a9\U00c5 \U2021\U00ae\U00ef\U2021\U00ae\U221e\U2021\U00ae\U00a7\U2021\U00ae\U00e6 \U2021\U00ae\U2122\U2021\U00a9\U00c5\U2021\U00ae\U221e\U2021\U00ae\U00f1\U2021\U00a9\U00c5 \U2021\U00ae\U00ae\U2021\U00ae\U00f8\U2021\U00ae\U221e\U2021\U00ae\U2260\U2021\U00ae\U00e2 \U2021\U00ae\U00ae\U2021\U00ae\U00f8\U2021\U00ae\U221e\U2021\U00ae\U00b5\U2021\U00a9\U00e0\U2021\U00ae\U221e\U2021\U00a9\U00c5 \U2021\U00ae\U00d6\U2021\U00ae\U00ef\U2021\U00ae\U00e6\U2021\U00ae\U2264 \U2021\U00ae\U00c6\U2021\U00a9\U00c7\U2021\U00ae\U221e\U2021\U00ae\U00a7\U2021\U00ae\U00f8 \U2021\U00ae\U00d6\U2021\U00ae\U00fa\U2021\U00a9\U00c7\U2021\U00ae\U00ae\U2021\U00a9\U00c4 \U2021\U00ae\U220f\U2021\U00a9\U00e0\U2021\U00ae\U2260\U2021\U00a9\U221e \U2021\U00ae\U00f3\U2021\U00a9\U00c5\U2021\U00ae\U221e \U2021\U00ae\U2122\U2021\U00a9\U00e7\U2021\U00ae\U221e\U2021\U00ae\U220f\U2021\U00ae\U00e6\U2021\U00ae\U00b6\U2021\U00ae\U00f8 \U2021\U2022\U2022";
pageNumber = 1;
},

这是我从中获取数据的数据库代码:

- (NSMutableArray*) tableBani:(NSString *)_query
{
NSMutableArray *drr=[[NSMutableArray alloc] init];
NSString *query;
query =_query;

const char *sql = [query cStringUsingEncoding:NSUTF8StringEncoding];
sqlite3_stmt *statement = nil;
if(sqlite3_prepare_v2(dataBaseConnection,sql, -1, &statement, NULL)!= SQLITE_OK)
{
NSAssert1(0,@"error preparing statement",sqlite3_errmsg(dataBaseConnection));
}
else
{
while (sqlite3_step(statement) == SQLITE_ROW)
{
[drr addObject:[NSDictionary dictionaryWithObjectsAndKeys:

[NSString stringWithFormat:@"%s", (char*)sqlite3_column_text(statement,0)],@"ID",
[NSString stringWithFormat:@"%s", (char*)sqlite3_column_text(statement,1)],@"pageNumber",
[NSString stringWithFormat:@"%s", (char*)sqlite3_column_text(statement,2)],@"PunjabiText",
[NSString stringWithFormat:@"%s", (char*)sqlite3_column_text(statement,3)],@"HindiText",
[NSString stringWithFormat:@"%s", (char*)sqlite3_column_text(statement,4)],@"EnglishText",
[NSString stringWithFormat:@"%s", (char*)sqlite3_column_text(statement,5)],@"EnglishTranslation",


nil]];

}
}

sqlite3_finalize(statement);

return drr;
}

我不知道如何获取旁遮普语或印地语格式的文本。请建议我如何从数据库中获取实际文本。我也尝试过将文本转换为 utf-8 但没有结果。请帮助我。

提前致谢。

最佳答案

只需尝试以下代码一次:

NSString *text = [NSString stringWithUTF8String:(char*)sqlite3_column_text(compiledStatement, 3)];

希望它能奏效。 :)

关于ios - 在sqlite中以unicode形式获取普通文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34396193/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com