I have a string containing a number in a non-ascii format e.g. unicode BENGALI DIGIT ONE (U+09E7) : "১"
How do I parse this as an integer in .NET?
Note: I’ve tried using int.Parse() specifying a bengali culture format with “bn-BD” as the IFormatProvider. Doesn’t work.
You could create a new string that is the same as the old string except the native digits are replaced with Latin decimal digits. This could be done reliably by looping through the characters and checking the value of
char.IsDigit(char). If this function returns true, then convert it withchar.GetNumericValue(char).ToString().Like this: