【发布时间】:2015-08-16 08:45:41
【问题描述】:
当我将其设置为 UILabel 时,我的 unicode 是 \u20AC,但我在标签上得到了 unicode。有时它会打印欧元,但主要是在标签上打印 unicode。
我的代码在这里
NSLog(@"Currecy %@",currencySymbol);
UILabel *priceLbl = [[UILabel alloc] initWithFrame:CGRectMake(180, 10, 45, 25)];
priceLbl.textColor = [UIColor whiteColor];
priceLbl.textAlignment = NSTextAlignmentCenter;
priceLbl.font = [UIFont fontWithName:@"ProximaNova-Bold" size:15];
priceLbl.tag = 1001;
fair = [NSString stringWithFormat:@"%d",arc4random()%50];
priceLbl.text = [NSString stringWithFormat:@"%@ %@",fair,currencySymbol];
输出 货币\u20AC
Printing description of priceLbl:
<UILabel: 0x7faade3095a0; frame = (185 10; 50 25); text = '\u20AC'; userInteractionEnabled = NO; tag = 1001; layer = <_UILabelLayer: 0x7faadbd91bb0>>
我正在尝试设置我想要的输出。例如
获取服务器响应
{
currency = "\\u20AC";
description = "You have been successfully logged in.";
}
and the currency symbol replacing "\\" with "\"
NSString *currency = [response[@"currency"] stringByReplacingOccurrencesOfString:@"\\\\" withString:@"\\"];
【问题讨论】:
-
@hasan83 请查看我的更新代码。
-
@halfer 是的,很有用
-
您的代码看起来不错。您可以添加currencySymbol 的声明以及如何为其分配值。或者你有货币的nsarray?
-
试试 priceLbl.text = [NSString stringWithFormat:@"%@ \u20ac",fair,currencySymbol];作为测试
-
@hasan83 来自服务器端的货币符号。当我试图在我的末尾设置相同的 unicode 获取欧元符号但是当它来自服务器端时它的打印 unicode。