用字符串Java替换阿拉伯语逗号和英语

时间:2017-06-03 05:56:03

标签: java string replace arabic

我正在尝试将阿拉伯数字字符替换为英语,我将使用以下方法替换任何阿拉伯字符实例,但唯一的问题是我无法使用特定方法将阿拉伯语逗号转换为英语逗号。

 public String convertNumbersToEnglish(String str) {
        if(str!=null && !str.equals("")){
            String answer = str;
            answer = answer.replace("١", "1");
            answer = answer.replace("٢", "2");
            answer = answer.replace("٣", "3");
            answer = answer.replace("٤", "4");
            answer = answer.replace("٥", "5");
            answer = answer.replace("٦", "6");
            answer = answer.replace("٧", "7");
            answer = answer.replace("٨", "8");
            answer = answer.replace("٩", "9");
            answer = answer.replace("٠", "0");
            answer = answer.replace("،",",");
            return answer;
        }else{
            return "";
        }

    }

1 个答案:

答案 0 :(得分:2)

试试你是否在Android

answer = answer.replace("\\u060C",",");