4 ms·
If you exclude surrogates, I think you can fit the rest of the codepoints in 20 bits. There would be no need for surrogates all Unicode scalars are representab
by recursive 3y ago
If you exclude surrogates, I think you can fit the rest of the codepoints in 20 bits. There would be no need for surrogates all Unicode scalars are representable elseways. Looks like an easy size win.
- Sniffnoy 3y agoThis is not true; the number of Unicode scalar values excluding surrogates is 17*2^16 - 2^11 = 1,112,064, which is larger than 2^20 = 1,048,576.
- nayuki 3y agoIn particular, UTF-16 surrogates use 2048 code points in the basic multilingual plane (BMP), but surrogates allow another 2^20 code points to be encodable in addition to the non-surrogate 65536−2048 code points of the BMP.