3 ms·
The Why is "Å" !== "Å" !== "Å"? section still strikes me as wrong. The strings are equal even when the representations differ.
by rurban 3y ago
The Why is "Å" !== "Å" !== "Å"? section still strikes me as wrong.
The strings are equal even when the representations differ.
- nextaccountic 3y agoThey are logically equal (that is, they represent the same text in an abstract way), but computing this equality in practice is expensive, because you first need to normalize the strings then compare. Most languages, when comparing strings, skip the normalization and just compare string bytes as is (or, if the string is interned, compare just the pointer)
- rurban 3y agoYou can easily do the comparison dynamically with checking for combining marks, and then do the proper lookup. No need to normalize everything, or even store the normalized variant. Though in a filesystem or username lookup you would only store it normalized.
- bajsejohannes 3y agoI just not sure why they put in the "Angstrom symbol" to begin with. If you do, then why isn't the "meter symbol" (m) also represented? Fortunately, it seems like it's marked as deprecated: https://en.wikipedia.org/wiki/Angstrom#Symbol https://en.wikipedia.org/wiki/Angstrom#Symbol
- jcranmer 3y ago> I just not sure why they put in the "Angstrom symbol" to begin with. Frequently, the answer to this is "some obscure character set had this as a distinct symbol." In this case, blame the Japanese: https://en.wikipedia.org/wiki/JIS_X_0208 https://en.wikipedia.org/wiki/JIS_X_0208 Which is why there's an 'mm' and 'cm' and other random symbols: https://www.compart.com/en/unicode/block/U+3300 https://www.compart.com/en/unicode/block/U+3300