Microsoft uses this rule as one of its complexity rules:
Any Unicode character that is categorized as an alphabetic character but is not uppercase or lowercase. This includes Unicode characters from Asian languages.
Testing for usual rules, like uppercase can be as simple as password.Any(char.IsUpper)
.
What test could I use in C# to test for alphabetic Unicode characters that are not uppercase or lowercase?
How about the literal translation of the rule:
password.Any(c => Char.IsLetter(c) &&
!Char.IsUpper(c) &&
!Char.IsLower(c))
When you convert ascii a
and A
to unicode, you'll get a
and A
so obviously, they are not the same.
Update: Here's an example of what I think you're asking:
var c = 'א';
c.Dump();
char.IsUpper(c).Dump("is upper"); // False
char.IsLower(c).Dump("is lower"); // False
char.IsLetterOrDigit(c).Dump("is letter or digit"); // True
char.IsNumber(c).Dump("is Number"); // False
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