Java has a Character.isDefined method, but there's no equivalent on the char class in .NET.
I'm aware that Microsoft's old Java libraries have this, but I don't want to depend on that library if I can avoid it.
Is there a built in equivalent in .NET somewhere? Or does calling all the available .is* methods combinatorially produce the same result? (e.g. char.IsLetter(x) || char.IsSymbol(x) etc....)
You could try with
int utf32 = 0x1FFFF;
string surrogate = Char.ConvertFromUtf32(utf32);
var isDefined = char.GetUnicodeCategory(surrogate, 0) != UnicodeCategory.OtherNotAssigned;
You can use char.GetUnicodeCategory(char)
directly if you have a character from the base BMP.
Note that each version of .NET supports different releases of Unicode, so what it will return is dependant of the version of Unicode used by the current version of .NET/current OS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With