开发者

UILabel + IRR, KRW and KHR currencies with wrong symbol

开发者 https://www.devze.com 2022-12-19 06:19 出处:网络
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.

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 ₩ (Ko开发者_高级运维rean 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];


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

0

精彩评论

暂无评论...
验证码 换一张
取 消