5 ms·
Not really. Unicode is a variable width abstract encoding; a single character can be made up of multiple code points. For Unicode, 32-bit bytes would be an inc
by ChrisSD 5y ago
Not really. Unicode is a variable width abstract encoding; a single character can be made up of multiple code points.
For Unicode, 32-bit bytes would be an incredibly wasteful in memory encoding.
- BlueTemplar 5y agoOne byte = one "character" makes for much easier programming. Text generally uses a small fraction of memory and storage these days.
- cygx 5y agoNot all user-perceived characters can be represented as a single Unicode codepoint. Hence, Unicode text encodings (almost[1]) always have to be treated as variable length, even UTF-32. [1] at runtime, you could dynamically assign 'virtual' codepoints to grapheme clusters and get a fixed-length encoding for strings that way
- jart 5y agoEven the individual unicode codepoints themselves are variable width if we consider that things like cjk and emoji take up >1 monospace cells.
- lanstin 5y agoEvery time I see one of these threads, my gratitude to only do backend grows. Human behavior is too complex, let the webdevs handle UI, and human languages are too complex, not sure what speciality handles that. Give me out of order packets and parsing code that skips a character if the packet length lines up just so any day. I am thankful that almost all the Unicode text I see is rendered properly now, farewell the little boxes. Good job lots of people.
- jart 5y agoI think we really have the iPhone jailbreakers to thank for that. U.S. developers were allergic almost offended by anything that wasn't ASCII and then someone released an app that unlocked the emoji icons that Apple had originally intended only for Japan. Emoji is defined in the astral planes so almost nothing at the time was capable of understanding them, yet were so irresistible that developers worldwide who would otherwise have done nothing to address their cultural biases immediately fixed everything overnight to have them. So thanks to cartoons, we now have a more inclusive world.
- londons_explore 5y agoI'm pretty sure Unicode was pretty widespread before the iphone/emoji popularity.
- cygx 5y agoThere's supporting Unicode, and 'supporting' Unicode. If you're only dealing with western languages, it's easy to fall into the trap of only 'supporting' Unicode. Proper emoji handling will put things like grapheme clusters and zero-width joiners on your map.
- kortex 5y ago> One byte = one "character" makes for much easier programming. Only if you are naively operating in the Anglosphere / world where the most complex thing you have to handle is larger character sets. In reality, there's ligatures, diacritics, combining characters, RTL, nbsp, locales, and emoji (with skin tones!). Not to mention legacy encoding. And no, it does not use a "small fraction of memory and storage" in a huge range of applications, to the point where some regions have transcoding proxies still.
- BlueTemplar 5y agoThis is not about covering ALL of Unicode. This is about starting to cover Unicode. "Anglosphere" would be just 7(&"8") bit ASCII, and it's the current situation where it takes quite a lot of skill and knowledge just to start learning how to properly deal with Unicode, because it's often not even taught ! IMHO 32-bit bytes would help tremendously with onboarding developers into Unicode, because it would force dumping ASCII-only as the starting point (and sadly, often ending point) for teaching how to deal with text. And who can blame the teachers, Unicode is already hard enough without even having to deal with the difficulties coming from having to explain its multi-byte representation... Last but not least : this would have forced standardization between the Unix world now on UTF-8 and the Windows world which is still stuck on UTF-16 (and Windows-1252 ?!?) for some of the core functions like filenames, which, for instance, still regularly results in issues working with files with non-ASCII filenames.
- a1369209993 5y ago> Unicode is a variable width abstract encoding; To be a bit more explicit: Unicode is a character encoding, to 20-and-a-half-bit 'bytes', that is variable-width in those 'bytes', even before considering how the 'bytes' are encoded to actual bytes. Eg "ψ̊" (greek small psi with ring above) is U+3C8 U+30A (two 'bytes').
- spacechild1 5y agoUnicode is not a text encoding. UTF8, UTF16, UTF32, etc. are text encodings. > a single character can be made up of multiple code points. It's really the other way round...
- spacechild1 5y agoOr maybe you meant to say: A single abstract character (or code point) can be made up of multiple code units. Unfortunately, the term “character“ alone is ambiguous because depending on the context it can refer to either code points or code units.
- ChrisSD 5y agoTo be technical, by "character" I mean "user-perceived character" or (in Unicode speak) "extended grapheme cluster". This is the thing a user will think of as one character when looking at it on their screen. A code point is the atomic unit of the abstract Unicode encoding. By "abstract" I mean it is not an actual text encoding you can write to a file. A code unit is the atomic unit of an actual text encoding, such as UTF-8, UTF-16LE or UTF-32LE (and their BE equivalents). --- So to put it together a "user-perceived character" is made up of one or more "code points". When implemented in an application, each "code point" is encoded using one or more "code units".
- spacechild1 5y agoNow that's a good summary! When talking about Unicode, some extra clarity can never hurt.