将阿拉伯数字转换为英文数字,​​并在 Dart 中进行反向转换

Convert arabic number to english number & the reverse in Dart

我想把阿拉伯数字换成英文数字

1-2-3-4-5-6-7-8-9 <== ١-٢-٣-٤-٥-٦-٧-٨-٩

阿拉伯语到英语

String replaceArabicNumber(String input) {
    const english = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
    const arabic = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];

    for (int i = 0; i < english.length; i++) {
      input = input.replaceAll(arabic[i], english[i]);
    }
    print("$input");
    return input;
  }

做相反的事情,用阿拉伯数字替换英文数字(English to Arabic)

 String replaceEnglishNumber(String input) {
    const english = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
    const arabic = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'];

    for (int i = 0; i < english.length; i++) {
      input = input.replaceAll(english[i], arabic[i]);
    }
    print("$input");
    return input;
  }