4 ms·
> UTF-8 is the standard for representing characters as eight bits, allowing every code-point between 0-127 to be stored in a single byte... Hmm... this makes i
by flohofwoe 7y ago
> UTF-8 is the standard for representing characters as eight bits, allowing every code-point between 0-127 to be stored in a single byte...
Hmm... this makes it sound like UTF-8 uses one byte per codepoint and can't encode codepoints beyond 127, when it actually is a variable-length encoding where one codepoint is encoded into 8 to 48 bits (1 to 6 bytes, although in practice 1 to 4 bytes are sufficient to encode all currently defined UNICODE codepoints).
The same is true for UTF-16, it's not "16 bits per codepoint", but variable length with either 16- or 32-bits per codepoint. Only UTF-32 is a fixed-width encoding.
Basically: all UTF encodings are able to encode all UNICODE codepoints.
- crehn 7y ago> In ASCII every character is a byte, and in Unicode, that’s often not true, a character can be 1, 2, 3, or more bytes. In a similar note, Unicode isn't really about bytes. Unicode is essentially just a huge map of numbers to characters descriptions. UTF encodings convert those numbers into a sequence of bytes, and vice versa.
- ZenPsycho 7y agoif only unicode were actually that simple.