UILabel + IRR, KRW and KHR currencies with wrong symbol

核能气质少年 提交于 2019-12-30 05:24:25

问题


I'm experiencing issues when converting decimal to currency for Korean Won, Cambodian Riel and Iranian Rial and showing the result to the UILabel text.

Conversion itself passes just fine and I can see correct currency symbol at the debugger, even the NSLog prints the symbol well.

If I assign this NSString instance to the UILabel text, the currency symbol is shown as a crossed box instead of the correct symbol. There is no other code between, does not matter what font I use.

I tried to print ₩ (Korean Won) using the unicode value (0x20A9) or even using UTF8 representation (\xe2\x82\xa9), but all I get is the crossed box on the label.

Any other supported currency in iPhone SDK and NSLocale (nearly 170 currencies) works perfectly fine no matter how exotic the currency is.

Anyone else experiencing the same problem? Is there a "cure" for this?

Thanks

EDIT:

-(NSString *)decimalToCurrency:(NSDecimalNumber *)value byLocale:(NSLocale *)locale
{
    NSNumberFormatter *fmt = [[NSNumberFormatter alloc] init];
    [fmt setLocale: locale];
    [fmt setNumberStyle: NSNumberFormatterCurrencyStyle];
    NSString *res = [fmt stringFromNumber: value];
    [fmt release];
    return res;
}

lbValue.text = [self decimalToCurrency: price byLocale: koreanLocale];

回答1:


Dear Serb, You have not any problem!!! you just use a limited (non)Unicode font.

in UI youshould display some character to users and IRR and KHR and etc are in different blocks of unicodeand the Fontyou are using to display to user shouldsupport allof them. I strongly recommand you to use Arial Unicode MS to ensure that you have Font issue or not.

if your problem resolved with font. You have to use a Unicode Font which support all of characters block - or create your own font



来源:https://stackoverflow.com/questions/2175963/uilabel-irr-krw-and-khr-currencies-with-wrong-symbol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!