Believe it or not, some characters turn into multiple characters when you convert them into uppercase.
For example, there is a set of special characters that look like two letters. One of these is Latin Small Ligature FI, which exists because of a typographic thing called “ligatures”. There are special characters for “FF”, “FL”, “FFI”, and “FFL” as well. These would turn into 2 or 3 characters from .toUppercase()
.
Another example is the German letter eszett. While an uppercase version exists and was officially approved by the Council for German Orthography in 2017, all browsers still convert the single letter "ß" into the two letters "SS".
Test program:
function countUpperDiff(input) {
console.log((input.toUpperCase().length - input.length) + ": " + input + " → " + input.toUpperCase());
}
console.log("This program prints how many characters longer the uppercase version becomes, followed by a before-and-after view.");
console.log("Some typographic ligatures exist in lowercase, but not uppercase.")
countUpperDiff("fix");
countUpperDiff("fix");
countUpperDiff("fly");
countUpperDiff("fly");
countUpperDiff("off");
countUpperDiff("off");
countUpperDiff("affix");
countUpperDiff("affix");
countUpperDiff("raffle");
countUpperDiff("raffle");
console.log("\nThe German letter ß is NOT converted into the capital letter ẞ, but into SS. This all-caps conversion is a problem for some words:")
countUpperDiff("in massen");
countUpperDiff("in maßen");
console.log("The first one means \"in massive amounts\", while the second one means \"in moderate amounts\".")
Output:
This program prints how many characters longer the uppercase version becomes, followed by a before-and-after view.
Some typographic ligatures exist in lowercase, but not uppercase.
0: fix → FIX
1: fix → FIX
0: fly → FLY
1: fly → FLY
0: off → OFF
1: off → OFF
0: affix → AFFIX
2: affix → AFFIX
0: raffle → RAFFLE
2: raffle → RAFFLE
The German letter ß is NOT converted into the capital letter ẞ, but into SS. This is a problem for some words:
0: in massen → IN MASSEN
1: in maßen → IN MASSEN
The first one means "in massive amounts", while the second one means "in moderate amounts".