Saturday, September 14, 2024

UPPERCASE is better than lowercase when comparing text

If locale-based string comparison is not available, converting to UPPERCASE is better than lowercase. For example,

uppercase("Straße") == uppercase("Strasse") == "STRASSE"

lowercase("Straße") != lowercase("Strasse"), because "straße" != "strasse"

For more on the ß character, see Eszett (ß = German sharp S).

If you are making a decision based on the result of a string comparison or a case change, be sure to avoid the invariant culture. See Invariant Culture.

No comments:

Post a Comment