为什么 nb_NO 和 nn_NO 的格式不同?我错过了什么?
#import <Foundation/Foundation.h>
void printPrice(NSNumber *price, NSLocale *locale)
{
NSNumberFormatter *numberFormatter = [NSNumberFormatter new];
numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
numberFormatter.locale = locale;
NSString *string = [numberFormatter stringFromNumber:@120];
printf("%s\n", [string UTF8String]);
}
int main(int argc, char *argv[]) {
@autoreleasepool {
{
NSString *identifier = @"nb_NO";
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:identifier];
printPrice(@120, locale);
}
{
NSString *identifier = @"nn_NO";
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:identifier];
printPrice(@120, locale);
}
}
}
输出
kr 120,00
120,00 kr