How to identify an alphabetical character that is not uppercase or lowercase

Microsoft uses this rule as one of its complexity rules:

Any Unicode character that is classified as an alphabetic character but is not uppercase or lowercase. This includes Unicode characters from Asian languages.

Testing common rules, such as uppercase letters, can be as simple as password.Any(char.IsUpper) .

What test can I use in C # to test for Unicode alphabetical characters that are not uppercase or lowercase?

+6
source share
2 answers

How about a literal translation of a rule:

 password.Any(c => Char.IsLetter(c) && !Char.IsUpper(c) && !Char.IsLower(c)) 
+8
source

When you convert ascii a and a to unicode, you will get a and A , obviously, they do not match.


Update: Here is an example of what I think you are 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 
+1
source

Source: https://habr.com/ru/post/973687/


All Articles