android - 英镑符号被损坏
我有一个例程根据输入的国家/地区代码传回货币符号,但英镑符号已损坏,我不确定为什么。当我传入 accountCurrency="GBP"
时,它返回的是“⣔,而不是预期的“£”。怎么了?
public static String findCurrencySymbol(String accountCurrency) {
if (accountCurrency == null || accountCurrency.trim().length() == 0) {
return "";
}
String curr = accountCurrency.toUpperCase();
if ("GBP".equals(curr)) {
return "£";
} else if ("USD".equals(curr)
|| "AUD".equals(curr)
|| "CAD".equals(curr)
|| "SGD".equals(curr)) {
return "$";
} else if ("EUR".equals(curr)) {
return "€";
} else {
// return raw currency code with whitespace attached
// should lead to display like: "YPY 12440.00"
return accountCurrency + " ";
}
}
编辑:其他值按预期返回。
I have a routine to pass back a currency sign based on a inputted country code, but the pound sign is being corrupted and I'm not sure why. Instead of the expected "£" when I pass in accountCurrency="GBP"
, it's returning "£". What is happening?
public static String findCurrencySymbol(String accountCurrency) {
if (accountCurrency == null || accountCurrency.trim().length() == 0) {
return "";
}
String curr = accountCurrency.toUpperCase();
if ("GBP".equals(curr)) {
return "£";
} else if ("USD".equals(curr)
|| "AUD".equals(curr)
|| "CAD".equals(curr)
|| "SGD".equals(curr)) {
return "$";
} else if ("EUR".equals(curr)) {
return "€";
} else {
// return raw currency code with whitespace attached
// should lead to display like: "YPY 12440.00"
return accountCurrency + " ";
}
}
edit: the other values are returning as expected.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否从某些 Word 文档中复制/粘贴了井号以及一些不可打印的字符?我见过很多这样的事情发生。
如果将其替换为符号的 unicode 值:“\u00A3”,会发生什么?
Could it be that you copy/pasted the pound sign from some word document along with some non printable characters? I've seen that happen a lot.
What happens if you replace it with the unicode value of the symbol: "\u00A3" ?