There are several ranges in Unicode characters that represent digits, for which char.IsDigit returns true. For example:
bool b1 = char.IsDigit('\uFF12'); // full-width '2' -> true
bool b2 = char.IsDigit('\u0665'); // true
bool b3 = char.IsDigit('5'); // true
I’m looking for a way to get the numeric equivalent of such characters. Note that int.Parse(...) DOES NOT work, as it expects the input characters to be in the base unicode range (‘0’ .. ‘9’).
This is equivalent to Java’s Character.digit(...) behavior.
Since the .NET framework’s char.IsDigit method correctly identifies such characters as digits, I’m expecting it to have this functionality as well, but I couldn’t find anything.
Have you tried
Char.GetNumericValue? (I’m just booting up my Windows laptop to check 🙂EDIT: Just tried it – looks like it works:
Note that this doesn’t just include digits – it’s any numeric character. However,
IsDigitis just for digits. For example: