Unicode在iOS中无法正常工作

时间:2015-08-16 08:45:42

标签: ios iphone unicode

当我在\u20AC上设置时,我的unicode是UILabel,但我在标签上获得了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];

输出 Currecy \ u20AC

Printing description of priceLbl:
<UILabel: 0x7faade3095a0; frame = (185 10; 50 25); text = '\u20AC'; userInteractionEnabled = NO; tag = 1001; layer = <_UILabelLayer: 0x7faadbd91bb0>>

enter image description here

我正试着按照自己的意愿设定输出。例如

enter image description here

获取服务器响应

{
    currency = "\\u20AC";
    description = "You have been successfully logged in.";
}

and the currency symbol replacing "\\" with "\"

NSString *currency = [response[@"currency"] stringByReplacingOccurrencesOfString:@"\\\\" withString:@"\\"];

1 个答案:

答案 0 :(得分:1)

请尝试:

var route = {
    _routes: {}, // The routes will be stored here

    add: function (url, action) {
    this._routes[url] = action;
    },
    run: function () {
        jQuery.each(this._routes, function (pattern) {
        if (location.href.match(pattern)) {
            // "this" points to the function to be executed
            this();
        }
    });
  }
}

// Will execute only on this page:
route.add('002.html',function (){
alert("Hello"); 
});

// You can even use regex-es:
route.add('.*.html',function (){
alert("Hellodaa"); 
});

route.run();