3 ms·
UTF-8 is an array of bytes (8 bit integers). UTF-16 is an array of 16 bit integers. UTF-32 is an array of 32 bit integers. The machine doesn't know anything
by ChrisSD 6y ago
UTF-8 is an array of bytes (8 bit integers).
UTF-16 is an array of 16 bit integers.
UTF-32 is an array of 32 bit integers.
The machine doesn't know anything about code points. If you want to index into the array you'll need to know the integer offset.
- dahfizz 6y ago> The machine doesn't know anything about code points. If you want to index into the array you'll need to know the integer offset. The machine doesn't know anything about Colors either. But if I defined a Color object, I would be able to put Color objects into an array and count how many Color objects I had. You're being needlessly reductive. > UTF-8 is an array of bytes (8 bit integers) UTF-8 encodes a codepoint with 1-4 single-byte code units. The reason UTF-8 exists is to provide a way for machines and developers to interact with unicode codepoints. Is a huffman code an array of bits? Or is it a list of symbols encoded using bits?
- ChrisSD 6y agoYou seem to be thinking of the abstraction as a concrete thing. A code point is like LLVM IR; an intermediary language for describing and converting between encodings. It is not a concrete thing in itself. The concrete thing we're encoding is human readable text. The atomic unit of which is the user perceived character. I'm curious, what use is knowing the number of code points in a string? It doesn't tell the user anything. It doesn't even tell the programmer anything actionable.