Skip to content

Instantly share code, notes, and snippets.

@chaudarywajid
Last active September 3, 2022 07:00
Show Gist options
  • Save chaudarywajid/15cf1de03172dd432d53cbb23a22bac5 to your computer and use it in GitHub Desktop.
Save chaudarywajid/15cf1de03172dd432d53cbb23a22bac5 to your computer and use it in GitHub Desktop.
Example in C#
var dictionary = new Dictionary<string, string>
{
{"٠", "0"},{"١", "1"},{"٢", "2"},{"٣", "3"},
{"٤", "4"},{"٥", "5"},{"٦", "6"},{"٧", "7"},
{"٨", "8"},{"٩", "9"},
};
string digit = input.Substring(this. txtNumber.Text.Length - 1);
char[] NumberChars = "٠١٢٣٤٥٦٧٨٩0123456789".ToCharArray();
int indexOf = digit.IndexOfAny(NumberChars);
if (indexOf == -1)
{
input = input.Remove(input.Length - 1);
await DisplayAlert("", "الحروف لا تقبل", "تم");
}
else
{
if (!string.IsNullOrEmpty(input) && dictionary.ContainsKey(digit)))
{
string englishDigit = dictionary[input];
input = input.Replace(digit, englishDigit);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment