小编Moh*_*aid的帖子

在Swift中将阿拉伯字符串转换为英文数字

如何将非英语数字转换为英文数字,​​如:Swift中的"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);
}
Run Code Online (Sandbox Code Playgroud)

ios swift

10
推荐指数
3
解决办法
8751
查看次数

标签 统计

ios ×1

swift ×1