java.util.Currency中的getSymbol()根据API级别返回不同的值

时间:2018-01-18 23:23:39

标签: java android currency

以下代码用于格式化正确货币的数字:

public static String getFormattedCurrency(String currencyCode, String currencyName, Number value) {

    //....

    NumberFormat format = NumberFormat.getCurrencyInstance(Locale.getDefault());                                           
    Currency currency = Currency.getInstance(currencyCode);                                                   
    format.setCurrency(currency);                                                                             
    if (format instanceof DecimalFormat) {                                                                    
        format.setMinimumFractionDigits(CURRENCY_MIN_FRACTION_DIGITS);                                        
    }                                                                                                         
    Log.d("Currency", "Symbol: " + currency.getSymbol() + ", Currency: " + currency + ", Locale: " + local);          
    return format.format(value);
}

currencyCode的价值是THB,即泰铢。在棒棒糖上,currency.getSymbol()返回฿,即泰铢的标志。但是,在Oreo上,相同的方法返回THB

为什么在这两个API级别之间返回不同的值?

1 个答案:

答案 0 :(得分:2)

基于this issue,它似乎是a Unicode decision