Case Conversion
The process of converting alphabetic characters between uppercase and lowercase forms. Conversion rules vary by language, and in some cases the character count changes after conversion.
Case conversion is one of the most frequently performed text processing operations. In English, the mapping between uppercase and lowercase is straightforward: "A" becomes "a" and "hello" becomes "HELLO," with all 26 letters having a clean one-to-one correspondence. However, when you look beyond English, case conversion turns out to be surprisingly complex.
The most well-known exception is the German Eszett "ß." Converting lowercase "ß" to uppercase produces "SS" (two characters), meaning the character count increases after uppercasing. Although Unicode 5.1 introduced the capital "ẞ" in 2017, German orthographic convention still treats "SS" as the standard uppercase form. Turkish presents another challenge: the uppercase of "i" is "İ" (with a dot), and the lowercase of "I" is "ı" (without a dot), which differs from English rules entirely.
In programming, case-insensitive comparison is a frequent requirement. The local part of an email address is case-sensitive, but the domain part is not. URL schemes (http/HTTP) and hostnames are case-insensitive, but the path component is case-sensitive. Handling these distinctions correctly requires knowing exactly which parts of a string should use case-insensitive comparison.
JavaScript's toLowerCase() and toUpperCase() are Unicode-aware, but locale-dependent conversions require toLocaleLowerCase(). Running 'I'.toLocaleLowerCase('tr') in a Turkish locale returns "ı," while an English locale returns "i." Ignoring locale in case conversion is a persistent source of internationalization bugs. Internationalization guides on Amazon discuss these pitfalls in detail.
Naming conventions in programming also rely on case patterns. camelCase, PascalCase, snake_case, kebab-case, and SCREAMING_SNAKE_CASE each carry semantic meaning. Converting between these conventions is not simple uppercasing or lowercasing; it requires recognizing word boundaries and applying the appropriate transformation to each segment.
From a character counting perspective, case conversion can change the length of a string. Beyond the German "ß" to "SS" example, Greek has "ς" (final sigma) that maps to "Σ" in uppercase and "σ" (medial sigma) in lowercase, with the lowercase form depending on position within a word. When applying case conversion to text with a character limit, you must account for the possibility that the converted string exceeds the original length.