Conceptcore
Case mapping and case folding
Also called case mapping, case folding, case conversion, upper case, lower case, title case, casefold, caseless matching, Turkish i.
Case mapping turns text into upper, lower or title case, and case folding erases case for comparison. Both follow Unicode data, can change the length and can depend on the locale.
- Applies to
- core-languages
Idea
A program changes the case of text to show it, such as a heading in capitals, and it ignores case to compare text, such as a user name or a file name. For ASCII, both jobs are simple: each of the 26 letters has one upper case and one lower case form. For the rest of Unicode, they are not. The Unicode Standard says that "Case mappings may produce strings of different lengths than the original"1, that some mappings depend on the letters around them, and that some depend on the language.
# Upper case can change the length: sharp s becomes "SS".
s = "straße"
print(s, s.upper(), len(s), len(s.upper()))
# Lower case depends on context: a final capital sigma becomes "ς".
w = "ΌΣΟΣ"
print(w, w.lower())
# Title case is not always upper case: the digraph "dz" has three forms.
dz = "dz"
print(dz, dz.upper(), dz.title())
# Lower case is not enough to compare. Case folding maps "ß" to "ss".
print(s.lower() == "STRASSE".lower(), s.casefold() == "STRASSE".casefold())
# The default mappings are not Turkish: "İ" lowercases to "i" and a combining dot.
dotted = "İ"
print(dotted.lower(), len(dotted.lower()), "i".upper())
straße STRASSE 6 7
ΌΣΟΣ όσος
dz DZ Dz
False True
i̇ 2 I
The German ß becomes the two letters SS in upper case, so the string grows from 6 to 7 characters. The Greek capital sigma becomes ς at the end of a word and σ in other places. The digraph dz has an upper case form DZ and a different title case form Dz. To compare straße with STRASSE, lower case is not enough, but case folding works. And the dotted capital İ becomes two code points in lower case, because the default mapping is not the Turkish one.
How it works
Three mappings. The Unicode Character Database gives each character an upper case, a lower case and a title case mapping. Title case is for the first letter of a word. For most characters it is the same as upper case, but "the two values are distinguished for these few digraph compatibility characters"1, such as dz. A simple mapping maps one code point to one code point. A full mapping can map one code point to several, and the extra mappings are in SpecialCasing.txt2. "The maximum string expansion as a result of case mapping in the Unicode Standard is three"1.
Complications. The Unicode Standard lists the cases that break the ASCII picture1:
- Change in length.
ß"expands when uppercased to the sequence of two characters"1SS, and the ligaturefibecomesFI2. A mapping can also change the length in bytes but not in characters: in UTF-8, the Turkish lower case formtopkapıtakes eight bytes, and the upper case formTOPKAPItakes seven1. - Context. The capital sigma
Σ"lowercases to U+03C3"1σ"if it is followed by another letter"1, and to the final sigmaςif it is not.SpecialCasing.txtmarks this mapping with the conditionFinal_Sigma2. - Locale. "The principal example of a case mapping that depends on the locale is Turkish"1. In Turkish,
imaps toİandımaps toI.SpecialCasing.txtlists these mappings for the languagestrandaz2. - Caseless characters. Most characters have no case, so "the process of uppercasing a string does not mean that it will no longer contain any lowercase letters"1.
- No round trip. "No casing operations are reversible"1. After
McGowanis upper cased, no case operation gets the original back.
Case folding. To compare text without case, a program does not compare upper case or lower case forms. It uses case folding, "the process of mapping characters of different case to a single form, so that case differences in strings are erased"1. Folding "is more than just conversion to lowercase"1: it maps ß to ss and both sigmas to σ. The data is in CaseFolding.txt, which "supports both implementations that require simple case foldings"3, where the length does not change, and implementations of full case folding, where the length can grow3. The file says that the "full case foldings are superior"3, because with them FUSS and Fuß match. Folding is "context-insensitive and language-independent (except for the optional, alternate Turkic case foldings)"1, and the file marks the Turkic entries with the status T3. A program usually keeps the original text and stores the folded form next to it, because "the original source string is not replaced by the folded string because that substitution may erase important information"1.
Folding is not collation. Case folding answers one question: are two strings the same if case is ignored? It does not sort, and it does not treat é and e as the same. For that, a program uses a collator with a strength or sensitivity setting, such as Intl.Collator or the Java Collator.
In languages
| Language | Verdict | Note |
|---|---|---|
| Python | Native | |
| C++ | Standard library | |
| Java | Native | |
| C | Standard library | |
| C# | Native | |
| JavaScript | Native | |
| TypeScript | Native | TypeScript uses the JavaScript methods toUpperCase, toLowerCase, toLocaleUpperCase and toLocaleLowerCase. No example file exists. |
| Go | Standard library | |
| Rust | Native | |
| Kotlin | Native | Kotlin has uppercase() and lowercase(), which take an optional Locale, and equals(other, ignoreCase = true). No example file exists because kotlinc is not installed. |
| SQL | Native | UPPER and LOWER change the case. A comparison that ignores case depends on the collation of the column. No example file exists. |
| Bash | Native | The expansions ${s^^} and ${s,,} change the case of each character by the locale. In a C.UTF-8 locale, ${s^^} keeps ß as ß. No example file exists. |
| PowerShell | Native | PowerShell strings are .NET strings, so ToUpper, ToLower and ToUpperInvariant work. The operator -eq ignores case, and -ceq does not. No example file exists because pwsh is not installed. |
| HTML | Does not apply | HTML has no string operations. The case of the text on the page comes from the text or from CSS. |
| CSS | Native | The property text-transform with the values uppercase, lowercase and capitalize changes the case of the text when the browser draws it. No example file exists. |
| Regular expressions | Native | The flag i, or the inline (?i), makes a match ignore case. Each engine decides whether it uses ASCII, simple or full case folding. |
| Language | Verdict | Mechanism |
|---|---|---|
| Python | native | upper, lower, title, capitalize, swapcase and casefold on str; full mappings; no locale rules |
| JavaScript | native | toUpperCase, toLowerCase; toLocaleUpperCase("tr"); no fold, Intl.Collator for caseless compare |
| TypeScript | native | the JavaScript methods |
| Java | native | toUpperCase(Locale), toLowerCase(Locale); equalsIgnoreCase; Character.toTitleCase |
| Kotlin | native | uppercase(), lowercase() with an optional Locale; equals(other, ignoreCase = true) |
| C# | native | ToUpper(CultureInfo), ToUpperInvariant; StringComparison.OrdinalIgnoreCase; TextInfo.ToTitleCase |
| Go | stdlib | strings.ToUpper, ToLower, ToTitle; ToUpperSpecial(unicode.TurkishCase, s); strings.EqualFold |
| Rust | native | str::to_uppercase, to_lowercase; char::to_uppercase gives an iterator; eq_ignore_ascii_case |
| C | stdlib | toupper and tolower on one byte, by the C locale; towupper on one wide character |
| C++ | stdlib | std::toupper on one char; the ctype facet of a std::locale |
| Bash | native | ${s^^} and ${s,,} for upper and lower case, by the locale |
| PowerShell | native | .NET ToUpper and ToLower; -eq ignores case, and -ceq does not |
| SQL | native | UPPER and LOWER; case-insensitive collations for comparison |
| Regex | native | the flag i, or (?i); Unicode case folding in some engines |
| HTML | n/a | no case operations; CSS styles the case of the text |
| CSS | native | text-transform: uppercase, lowercase and capitalize, with the lang of the element |
Python, JavaScript, Java and Rust apply the full mappings, so ß becomes SS and the length changes. Python casefold maps ß to ss4, and its documentation calls case folding "similar to lowercasing but more aggressive because it is intended to remove all case distinctions in a string"4. In Java, "Since case mappings are not always 1:1 char mappings, the resulting String and this String may differ in length"5. MDN says the same for JavaScript: "the length of the result string can differ from the input length"6. Rust returns a new String "Since some characters can expand into multiple characters when changing the case"7, and char::to_uppercase "Returns an iterator that yields the uppercase mapping of this char as one or more chars"8.
Go and C# map one code point or one char at a time, so ß stays ß in upper case and the length does not change. Go EqualFold uses "simple Unicode case-folding"9, and unicode.SimpleFold walks the set of code points that fold together10. C and C++ map one byte at a time, and in the default C locale toupper changes only the letters a to z11.
The locale is the second split. Java, JavaScript, C# and Go have Turkish rules: Java toUpperCase(Locale), JavaScript toLocaleUpperCase, a .NET CultureInfo, and Go unicode.TurkishCase. Python and Rust do not. The Rust to_uppercase "does not handle language-specific casing, like Turkish and Azeri I/ı/İ/i"7. The default methods of Java and .NET use the current locale, and the documentation warns about it. The Java documentation gives an example: toLowerCase() on TITLE returns tıtle in a Turkish locale, and it names "programming language identifiers, protocol keys, and HTML tags"5 as text that needs toLowerCase(Locale.ROOT)5. The .NET guide recommends StringComparison.Ordinal or StringComparison.OrdinalIgnoreCase "as your safe default for culture-agnostic string matching"12.
The example files show each language on the same words. Python shows capitalize and title, the loss of McGowan, casefold on ß, fi and Greek, and a Turkish workaround with translate. JavaScript shows the full mappings, the Turkish locale and a collator that ignores case but not accents. Java shows Locale.ROOT and the Turkish locale, the length rule of equalsIgnoreCase, title case of dz, and a char that cannot expand. C# shows that ß stays ß, the Turkish culture, OrdinalIgnoreCase and ToTitleCase. Go shows simple mappings, TurkishCase, EqualFold and the fold orbit of K. Rust shows the iterator of char::to_uppercase, the final sigma and the missing Turkish rules. C and C++ show byte-by-byte mappings and an ASCII-only compare.
# capitalize changes the first character, and title changes each word.
s = "they're bill's friends"
print(s.capitalize())
print(s.title())
# Case mappings are not reversible.
name = "McGowan"
print(name.upper().lower(), name.lower().title())
# casefold is more than lower: it also folds "ß" and the ligature "fi".
for w in ["Straße", "file", "ΌΣΟΣ"]:
print(w, w.lower(), w.casefold())
# Python has no Turkish rules. A program can map i and ı first, then call upper.
tr_upper = str.maketrans({"i": "İ", "ı": "I"})
print("istanbul ılık".translate(tr_upper).upper())
# Caseless characters stay as they are, so isupper looks only at the cased ones.
print("ABC 123".isupper(), "日本".upper() == "日本")
They're bill's friends
They'Re Bill'S Friends
mcgowan Mcgowan
Straße straße strasse
file file file
ΌΣΟΣ όσος όσοσ
İSTANBUL ILIK
True True
- Verdict: native.
capitalizechanges only the first character, andtitlestarts a new word after each apostrophe, so it givesThey'Re. Afterupperorlower,McGowancannot come back.lowerkeepsßandfi, andcasefoldmaps them tossandfi.lowergives the final sigmaς, andcasefoldmaps it toσ. Python has no Turkish rules, so the example mapsiandıwithtranslatebefore it callsupper.isupperlooks only at cased characters, andupperdoes not change日本.
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <string>
int main() {
// std::toupper takes one char, so a std::transform maps byte by byte.
// The cast to unsigned char avoids undefined behaviour for bytes over 0x7F.
std::string s = "straße";
std::ranges::transform(s, s.begin(), [](unsigned char c) { return static_cast<char>(std::toupper(c)); });
std::printf("%s %zu\n", s.c_str(), s.size());
// A caseless compare of ASCII letters with a predicate.
auto same = [](unsigned char a, unsigned char b) { return std::tolower(a) == std::tolower(b); };
std::string a = "Content-Type", b = "content-type";
std::printf("%d\n", a.size() == b.size() && std::ranges::equal(a, b, same));
// The bytes of "ß" are not letters in the "C" locale, so they do not change.
std::string u8 = "ß";
std::printf("%02X %02X %d\n", static_cast<unsigned char>(u8[0]), static_cast<unsigned char>(u8[1]),
std::isalpha(static_cast<unsigned char>(u8[0])) != 0);
}
STRAßE 7
1
C3 9F 0
- Verdict: stdlib.
std::touppertakes onechar, sostd::ranges::transformmaps byte by byte andßkeeps its 2 bytes. A predicate withstd::tolowerfindsContent-Typeandcontent-typeequal. The bytesC3 9Fofßare not letters in the C locale, soisalphagives 0.
import java.util.Locale;
public class Main {
public static void main(String[] args) {
Locale tr = Locale.forLanguageTag("tr");
// toUpperCase maps "ß" to "SS", so the length changes.
String s = "straße";
String up = s.toUpperCase(Locale.ROOT);
System.out.println(up + " " + s.length() + " " + up.length());
// The Turkish locale changes the mappings of i and I.
System.out.println("title".toUpperCase(Locale.ROOT) + " " + "title".toUpperCase(tr));
System.out.println("TITLE".toLowerCase(Locale.ROOT) + " " + "TITLE".toLowerCase(tr));
// equalsIgnoreCase compares code point by code point, so the lengths must match.
System.out.println("straße".equalsIgnoreCase("STRASSE") + " " + "ΌΣΟΣ".equalsIgnoreCase("όσος"));
// Character has a title case mapping that differs from upper case for "dz".
char dz = 'dz';
System.out.println(Character.toUpperCase(dz) + " " + Character.toTitleCase(dz));
// A char method cannot expand: Character.toUpperCase('ß') returns 'ß'.
System.out.println(Character.toUpperCase('ß'));
}
}
STRASSE 6 7
TITLE TİTLE
title tıtle
false true
DZ Dz
ß
- Verdict: native.
toUpperCase(Locale.ROOT)mapsßtoSS, so the length goes from 6 to 7. The Turkish locale givesTİTLEandtıtle.equalsIgnoreCasecompares code point by code point, sostraßeandSTRASSEare not equal because their lengths differ, but the two sigma forms are equal.Character.toTitleCasegivesDz, andCharacter.toUpperCase('ß')returnsß, because onecharcannot become two.
#include <ctype.h>
#include <stdio.h>
#include <string.h>
/* ascii_casecmp compares two strings and ignores ASCII case only. */
static int ascii_casecmp(const char *a, const char *b) {
for (;; a++, b++) {
int x = tolower((unsigned char)*a), y = tolower((unsigned char)*b);
if (x != y || x == '\0') return x - y;
}
}
int main(void) {
/* toupper works on one byte. In the "C" locale it changes only a to z. */
char s[] = "straße";
for (char *p = s; *p; p++) *p = (char)toupper((unsigned char)*p);
printf("%s %zu\n", s, strlen(s));
/* In ASCII, upper and lower case differ in one bit, 0x20. */
printf("%c %c %02X\n", 'a' ^ 0x20, 'A' | 0x20, 'a' ^ 'A');
/* A caseless compare in C must be written, or taken from POSIX strcasecmp. */
printf("%d %d\n", ascii_casecmp("Hello", "hELLO") == 0, ascii_casecmp("straße", "STRASSE") == 0);
return 0;
}
STRAßE 7
A a 20
1 0
- Verdict: stdlib.
toupperworks on one byte, so the two bytes ofßdo not change, and the length stays 7 bytes. Upper case and lower case ASCII letters differ in the bit 0x20. The C standard library has no caseless compare, soascii_casecmpcompares withtolower. It matchesHelloandhELLO, but notstraßeandSTRASSE.
using System.Globalization;
// .NET maps one char to one char, so "ß" stays "ß" and the length does not change.
string s = "straße";
Console.WriteLine($"{s.ToUpperInvariant()} {s.Length} {s.ToUpperInvariant().Length}");
// A CultureInfo gives the Turkish rules.
var tr = new CultureInfo("tr-TR");
Console.WriteLine($"{"title".ToUpperInvariant()} {"title".ToUpper(tr)}");
Console.WriteLine($"{"TITLE".ToLowerInvariant()} {"TITLE".ToLower(tr)}");
// OrdinalIgnoreCase compares char by char after a simple case mapping.
Console.WriteLine(string.Equals("ΌΣΟΣ", "όσος", StringComparison.OrdinalIgnoreCase));
Console.WriteLine(string.Equals("straße", "STRASSE", StringComparison.OrdinalIgnoreCase));
// A culture-aware comparison that ignores case.
Console.WriteLine(string.Compare("Résumé", "RÉSUMÉ", CultureInfo.InvariantCulture, CompareOptions.IgnoreCase) == 0);
// TextInfo.ToTitleCase capitalizes each word, but it keeps words in all capitals.
TextInfo ti = CultureInfo.InvariantCulture.TextInfo;
Console.WriteLine(ti.ToTitleCase("hello WORLD from nasa"));
STRAßE 6 6
TITLE TİTLE
title tıtle
True
False
True
Hello WORLD From Nasa
- Verdict: native.
ToUpperInvariantmaps onecharto onechar, soßstaysßand the length stays 6. Thetr-TRculture givesTİTLEandtıtle.OrdinalIgnoreCasefinds the two sigma forms equal, but notstraßeandSTRASSE. A comparison withInvariantCultureandIgnoreCasefindsRésuméandRÉSUMÉequal.ToTitleCasecapitalizes each word and keepsWORLDin capitals.
// toUpperCase uses the full mappings, so the length can change.
const s = "straße";
console.log(s.toUpperCase(), s.length, s.toUpperCase().length);
// toLowerCase handles the final sigma.
console.log("ΌΣΟΣ".toLowerCase());
// The locale methods apply the Turkish rules for "tr".
console.log("istanbul".toUpperCase(), "istanbul".toLocaleUpperCase("tr"));
console.log("TITLE".toLowerCase(), "TITLE".toLocaleLowerCase("tr"));
// JavaScript has no case fold. A collator with sensitivity "accent" ignores case but not accents.
const collator = new Intl.Collator("fr", { sensitivity: "accent" });
const r = "R\u00e9sum\u00e9";
console.log(collator.compare(r, r.toUpperCase()) === 0, collator.compare(r, "RESUME") === 0);
console.log("Straße".toLowerCase() === "STRASSE".toLowerCase());
// Upper case and then lower case is a common approximation of a fold.
const fold = (x) => x.toUpperCase().toLowerCase();
console.log(fold("Straße") === fold("STRASSE"), fold("ΌΣΟΣ") === fold("όσος"));
STRASSE 6 7
όσος
ISTANBUL İSTANBUL
title tıtle
true false
false
true true
- Verdict: native.
toUpperCasemapsßtoSS, so the length goes from 6 to 7.toLowerCasegives the final sigma.toLocaleUpperCase("tr")givesİSTANBUL, andtoLocaleLowerCase("tr")givestıtle. JavaScript has no fold function. A collator with the sensitivityaccentfindsRésuméandRÉSUMÉequal, but notRésuméandRESUME. Lower case alone does not matchStraßeandSTRASSE, but upper case and then lower case does.
package main
import (
"fmt"
"strings"
"unicode"
)
func main() {
// strings.ToUpper maps each rune to one rune, so "ß" stays "ß".
s := "straße"
fmt.Println(strings.ToUpper(s), len([]rune(s)), len([]rune(strings.ToUpper(s))))
// unicode.TurkishCase gives the Turkish rules for i and I.
fmt.Println(strings.ToUpper("istanbul"), strings.ToUpperSpecial(unicode.TurkishCase, "istanbul"))
fmt.Println(strings.ToLower("TITLE"), strings.ToLowerSpecial(unicode.TurkishCase, "TITLE"))
// strings.ToLower has no context rule, so a final sigma stays "σ".
fmt.Println(strings.ToLower("ΌΣΟΣ"))
// EqualFold uses simple case folding: the sigmas match, "ß" and "SS" do not.
fmt.Println(strings.EqualFold("ΌΣΟΣ", "όσος"), strings.EqualFold(s, "STRASSE"))
// SimpleFold walks the orbit of runes that fold together: K, k and the Kelvin sign.
r := 'K'
var orbit []string
for i := 0; i < 3; i++ {
r = unicode.SimpleFold(r)
orbit = append(orbit, fmt.Sprintf("%U", r))
}
fmt.Println(strings.Join(orbit, " "))
// ToTitle and ToUpper differ for the digraph "dz".
fmt.Println(string(unicode.ToUpper('dz')), string(unicode.ToTitle('dz')))
}
STRAßE 6 6
ISTANBUL İSTANBUL
title tıtle
όσοσ
true false
U+006B U+212A U+004B
DZ Dz
- Verdict: stdlib.
strings.ToUppermaps each rune to one rune, soßstaysß.ToUpperSpecialandToLowerSpecialwithunicode.TurkishCasegive the Turkish forms.strings.ToLowerhas no final sigma rule, so the result ends inσ.EqualFoldmatches the sigma forms but notßandSS.unicode.SimpleFoldgoes fromKtok, then to the Kelvin sign U+212A, and back toK.unicode.ToTitlegivesDz.
fn main() {
// to_uppercase returns a new String, because "ß" becomes "SS".
let s = "straße";
let up = s.to_uppercase();
println!("{} {} {}", up, s.chars().count(), up.chars().count());
// char::to_uppercase returns an iterator, because one char can map to several.
let sharp: Vec<char> = 'ß'.to_uppercase().collect();
println!("{:?}", sharp);
// str::to_lowercase handles the final sigma. char::to_lowercase cannot see the context.
let w = "ΌΣΟΣ";
let by_char: String = w.chars().flat_map(|c| c.to_lowercase()).collect();
println!("{} {}", w.to_lowercase(), by_char);
// The default mappings have no Turkish rules.
let dotted: String = 'İ'.to_lowercase().collect();
println!("{} {} {}", "i".to_uppercase(), dotted, dotted.chars().count());
// eq_ignore_ascii_case ignores only ASCII case.
println!("{} {}", "HELLO".eq_ignore_ascii_case("hello"), "ΌΣΟΣ".eq_ignore_ascii_case("όσος"));
// A simple caseless compare: compare the lower case forms of the upper case forms.
let fold = |x: &str| x.to_uppercase().to_lowercase();
println!("{}", fold("Straße") == fold("STRASSE"));
}
STRASSE 6 7
['S', 'S']
όσος όσοσ
I i̇ 2
true false
true
- Verdict: native.
to_uppercasereturns a newString, and the length goes from 6 to 7charvalues.'ß'.to_uppercase()yields twocharvalues.str::to_lowercasegives the final sigma, and a loop overchar::to_lowercasedoes not.'İ'.to_lowercase()gives two code points, because the default mappings have no Turkish rules.eq_ignore_ascii_caseignores only ASCII case, so the Greek words are not equal. Upper case and then lower case matchesStraßeandSTRASSE.
Variations and related ideas
- ASCII-only case. Protocol keywords, HTTP header names and many identifiers are ASCII, and their rules ignore only ASCII case. Rust
eq_ignore_ascii_case, Ctolowerin the C locale and C#OrdinalIgnoreCaseon ASCII text fit this job, and they do not depend on the locale. - Title case of words. The Unicode title case mapping is for one letter. To title case a heading, a program must also find the words, and the rules depend on the language: "The choice of which words to titlecase in headings and titles is dependent on language and local conventions"1. Python
titleuses "a simple language-independent definition of a word as groups of consecutive letters"4, sothey'rebecomesThey'Re. Go deprecatedstrings.Titlebecause "The rule Title uses for word boundaries does not handle Unicode punctuation properly"9. - Case-insensitive identifiers. Some languages, file systems and protocols ignore case in names. Each one must pick ASCII folding, simple folding or full folding, and a locale.
- Normalization. Case folding "does not preserve normalization formats"3, so a program that compares text normalizes it after it folds it, or it uses a canonical caseless match.
Pitfalls
- The Turkish i.
toLowerCase()with no locale in Java, orToLower()in .NET, givestıtleon a machine with a Turkish locale, and a keyword match fails. PassLocale.ROOTor use the invariant culture for text that is not for people. - Lower case to compare.
a.lower() == b.lower()fails forstraßeandSTRASSE. Use a fold, such ascasefoldin Python. - The length after a case change. A buffer of the same size is too small for the upper case form of
ßorfi, and an index into the old string does not fit the new one. - One character at a time. A loop that calls
toupperon each byte, orchar::to_lowercaseon eachchar, misses the final sigma and the expansions. Call the function on the whole string. - Bytes over 0x7F in C.
toupperon a plaincharthat is negative is undefined behaviour: "If the value of ch is not representable as unsigned char and does not equal EOF, the behavior is undefined"11. Cast tounsigned charfirst.
Cost
A case mapping reads each code point once and looks it up in a table, so it is O(n). A full mapping can make the result up to three times as long in code points, so it allocates a new string. An ASCII mapping can work in place, because it does not change the length in bytes. A simple mapping keeps the number of code points, but in UTF-8 it can still change the number of bytes1. To compare without case, a fold of both strings costs O(n) time and memory each time. A program that compares the same text often stores the folded form once. A compare function such as Go EqualFold takes the two strings and returns a bool, so the caller does not keep folded copies9.
History
In ASCII, upper and lower case letters differ in one bit. In May 1963 a CCITT working party proposed to put the lower case letters in columns 6 and 7 of the code table, which "caused the characters to differ in bit pattern from the upper case by a single bit, which simplified case-insensitive character matching and the construction of keyboards and printers"13. That one bit is the reason why C code can map case with c ^ 0x20, and why the ASCII rules stayed the default in many languages. Unicode later moved the rules into data files: the simple mappings in the character database, the special and locale mappings in SpecialCasing.txt, and the folds in CaseFolding.txt. The data still changes with the languages: German has the capital ẞ, and "In 2017, the Council for German Orthography officially adopted a capital form ⟨ẞ⟩ as an acceptable variant"14. The default mapping still makes ß into SS, but CaseFolding.txt folds ẞ and ß to the same ss3.
References
- The Unicode Standard, Version 17.0, Chapter 5, Implementation Guidelines, 5.18 Case Mappings
- SpecialCasing-17.0.0.txt, Unicode Character Database, Unconditional mappings; Conditional Mappings; Language-Sensitive Mappings
- CaseFolding-17.0.0.txt, Unicode Character Database, File header; entries 00DF, 0130, 03C2
- Built-in Types, Python documentation, str.casefold; str.upper; str.title
- Class String, Java SE 25 API, toLowerCase(); toUpperCase(Locale); equalsIgnoreCase
- String.prototype.toLocaleUpperCase(), MDN Web Docs, Description
- Primitive Type str, The Rust Standard Library, to_uppercase; to_lowercase
- Primitive Type char, The Rust Standard Library, to_uppercase
- Package strings, Go standard library, EqualFold; ToUpper; ToUpperSpecial; Title
- Package unicode, Go standard library, SimpleFold; SpecialCase; TurkishCase
- toupper, cppreference.com (C), Description; Parameters
- Best practices for comparing strings in .NET, Recommendations for string usage; String comparisons that use the current culture
- ASCII, Wikipedia, History
- ß, Wikipedia, Introduction
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag 57XKP7 Edit this page History Report an error Markdown