Last active
September 3, 2022 07:00
-
-
Save chaudarywajid/15cf1de03172dd432d53cbb23a22bac5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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