java - Why CaseInsensitiveComparator does not uppercase and lowercase comparisions -


this question has answer here:

i looking @ code of caseinsensitivecomparator not understand following piece of code

               if (c1 != c2) {                 c1 = character.touppercase(c1);                 c2 = character.touppercase(c2);                 if (c1 != c2) {                     c1 = character.tolowercase(c1);                     c2 = character.tolowercase(c2);                     if (c1 != c2) {                         // no overflow because of numeric promotion                         return c1 - c2;                     }                 }             } 

what purpose of comparing characters in both uppercase , lowercase form? isn't 1 of them sufficient? suspecting characters can equal when lowercase not equal when uppercase?

from unicode standard:

in addition, because of vagaries of natural language, there situations 2 different unicode characters have same uppercase or lowercase

so find lowercase of letters same uppercase different , hence comparison.

also check source says:

unfortunately, conversion uppercase not work georgian alphabet, has strange rules case conversion. need make 1 last check before exiting.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -