从\ uXXXX表示创建一个NSString

时间:2010-10-16 15:32:13

标签: iphone utf-8

我需要在我的UI中显示EURO(€,$,£)符号。 这些符号存储在带有\ uXXXX表示的SQLite数据库中。 我如何创建NSString表示?

以下是代码示例:

NSString *currency = [[OptionDAO sharedInstance] readStringOption:@"TEST" 
                                                          strName:@"currency" 
                                                         strGroup:@"NONE"]; // currency now contains "\u34AC" for instance.

2 个答案:

答案 0 :(得分:0)

NSString *aString = [NSString stringWithUTF8String:"To be continued\u2026"];

(由http://www.cocoadev.com/index.pl?UniCode提供)

答案 1 :(得分:0)

我找到了解决方案。 `NSString * currency = [[OptionDAO sharedInstance] readStringOption:[ctrlParent selectedCompany] .SupplierID                                                           则strName:@ “货币”                                                          strGroup:@ “NONE”];

NSData *ccc = [currency dataUsingEncoding:NSUTF8StringEncoding];
currency = [currency length] != 0 ? [NSString stringWithUTF8String:[ccc bytes]] : @"$";`