如何将非英语数字转换为英文数字,如:
斯威夫特的“3486912881”到“3486912881”
或者我想接受英文数字并获得其他人.
斯威夫特的“3486912881”到“3486912881”
或者我想接受英文数字并获得其他人.
在Java Android中,这段代码对我有用:
private static String arabicToDecimal(String number) {
char[] chars = new char[number.length()];
for(int i=0;i<number.length();i++) {
char ch = number.charat(i);
if (ch >= 0x0660 && ch <= 0x0669)
ch -= 0x0660 - '0';
else if (ch >= 0x06f0 && ch <= 0x06F9)
ch -= 0x06f0 - '0';
chars[i] = ch;
}
return new String(chars);
}
解决方法
喜欢
let NumberStr: String = "٢٠١٨-٠٦-٠٤"
let Formatter = NumberFormatter()
Formatter.locale = NSLocale(localeIdentifier: "EN") as Locale!
let final = Formatter.number(from: NumberStr)
if final != 0 {
print("\(final!)")
}
产量