Currencies UILabel + IRR, KRW and KHR with the wrong character

I am having problems converting the decimal amount to the currency for the Korean Won, Cambodian Rile and the Iranian Rial and displaying the result in UILabel text.

The conversion itself goes very well, and I can see the correct currency symbol in the debugger, even NSLog prints the symbol well.

If I assign UILabel to this NSString instance, the currency symbol appears as a crossed field instead of the correct symbol. There is no other code between me, it doesn't matter which font I use.

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

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

Is anyone else experiencing the same problem? Is there a “cure” for this?

thank

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];
+3
source share
1 answer

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

, IRR KHR .. unicode Fontyou , . Arial Unicode MS, , .

. Unicode, ,

0

Source: https://habr.com/ru/post/1730842/


All Articles